473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Speed inprovement

Hi,

I am building an application that need high speed of execution. There
is a lot of string parsing that I do in VB.NET.

Do I gain in speed if all that string parsing is made in a dll coded in
C or C++ and added to my VB.NET application?

I would also gain the advantage of portability, but my main concern is
speed of execution.

Thank you!

Marty
Nov 21 '05 #1
12 1300
> I am building an application that need high speed of execution. There is
a lot of string parsing that I do in VB.NET.

Do I gain in speed if all that string parsing is made in a dll coded in C
or C++ and added to my VB.NET application?

I would also gain the advantage of portability, but my main concern is
speed of execution.


Can be, however why would it?

There are very fast classes for string handling in VBNet. But there can
always situations which cannot be handled.

Cor
Nov 21 '05 #2
Hi Cor,

Here is the idea of what I want to do:

Here is a description of the strings I have to parse. Approx 100
different string of approx 60 to 100 bytes long.

Each string contain concatened fields. Some are non formatted numbers,
date, time, and many others specific fields.

There is no way to split those string and get a easy to read array. For
each string I have to use mid$ and get each separate fields and format
it in the way it should be. Some fields need basic mathematic
calculation to have a human readable number.

At this point I was thinking to make the C dll for reading purpose, I
mean, pass the raw string to the dll, and it return a parsed array of
all fields (of data type string).

In this VB.NET code I use the string.substring() function to to get
parts of string. Is there a better VB.NET handling for that?

Do you think I could gain speed using a C/C++ dll for this situation?

Thank you for your reply.
Marty

Cor Ligthert wrote:
I am building an application that need high speed of execution. There is
a lot of string parsing that I do in VB.NET.

Do I gain in speed if all that string parsing is made in a dll coded in C
or C++ and added to my VB.NET application?

I would also gain the advantage of portability, but my main concern is
speed of execution.

Can be, however why would it?

There are very fast classes for string handling in VBNet. But there can
always situations which cannot be handled.

Cor

Nov 21 '05 #3
Marty,

Some things I know

When you can do a character operation let that go before a string operation.

A problem is that there is no consequenty where a Microsoft.Visual Basic
method is quicker than a System method. It differs, the Instr is quicker
than the IndexOf (with strings) however there are others who are *much*
slower.

The problem is that mixing those up is confusing because of the use of the
character indexer which start in System at Zero and on MVB with the First
(1).

The regular expression is almost always (very) slow however when you can do
a lot in one search than it can become an advantage.

Never use in .Net whatever language you use things as:
dim str as string = "I" & " am" & " Cor"
or even worse
dim str as string = "It is " + "ToDay " + "march " + "1" + "8"
For that is the stringbuilder and than do it even with smallest parts.
Every string that has the slightest change will me made new.
(A string is immutable).

When you can put your strings as stringbuilder parts in a arraylist, which
is fast as well, than I assume that you can get your highest performance.

You see that there are a lot of possibilities which you don't get with a raw
language as C where you do it yourself. My opinion is that you will loose
that.

However I can be wrong of course, it is just what I assume.

I hope this helps

Cor
Nov 21 '05 #4
Not so long ago i had the folowing task at my job
Write a program that can read a MYSQL dump file of mutiple gigabytes
( the tests were between 2 and 7 gb ) and that wil on the fly convert the
MYSQL data types to SQL server datatypes
and import the data to MS SQL server 2000

well before i used the stringbuilder this took hours ,,,,, after using the
string builder it took minutes

I am really impressed about the string and IO handling of .Net and know that
if you use it at the right way it will be as fast as using a low level
language in a verry very optimized way

M. Posseth


"Marty" <xm******@hotmail.com> wrote in message
news:hrC_d.45890$ZO2.33318@edtnps84...
Hi,

I am building an application that need high speed of execution. There
is a lot of string parsing that I do in VB.NET.

Do I gain in speed if all that string parsing is made in a dll coded in
C or C++ and added to my VB.NET application?

I would also gain the advantage of portability, but my main concern is
speed of execution.

Thank you!

Marty

Nov 21 '05 #5
With only 100 strings of 60 bytes long, it really doesn't matter as the speed
will be blazingly fast so long as you use stringbuilder instead of the + and
& operators. However, even with them, you applicaiton is light and speed
won't be a problem. I would suggest you might want to convert the strings
into char arrays as this might be faster and easier than using mid. You can
check each character in a loop and use stringbuilder to construct your
substrings.

"Marty" wrote:
Hi Cor,

Here is the idea of what I want to do:

Here is a description of the strings I have to parse. Approx 100
different string of approx 60 to 100 bytes long.

Each string contain concatened fields. Some are non formatted numbers,
date, time, and many others specific fields.

There is no way to split those string and get a easy to read array. For
each string I have to use mid$ and get each separate fields and format
it in the way it should be. Some fields need basic mathematic
calculation to have a human readable number.

At this point I was thinking to make the C dll for reading purpose, I
mean, pass the raw string to the dll, and it return a parsed array of
all fields (of data type string).

In this VB.NET code I use the string.substring() function to to get
parts of string. Is there a better VB.NET handling for that?

Do you think I could gain speed using a C/C++ dll for this situation?

Thank you for your reply.
Marty

Cor Ligthert wrote:
I am building an application that need high speed of execution. There is
a lot of string parsing that I do in VB.NET.

Do I gain in speed if all that string parsing is made in a dll coded in C
or C++ and added to my VB.NET application?

I would also gain the advantage of portability, but my main concern is
speed of execution.

Can be, however why would it?

There are very fast classes for string handling in VBNet. But there can
always situations which cannot be handled.

Cor

Nov 21 '05 #6
With only 100 strings of 60 bytes long, it really doesn't matter as the speed
will be blazingly fast so long as you use stringbuilder instead of the + and
& operators. However, even with them, you applicaiton is light and speed
won't be a problem. I would suggest you might want to convert the strings
into char arrays as this might be faster and easier than using mid. You can
check each character in a loop and use stringbuilder to construct your
substrings.

"Marty" wrote:
Hi Cor,

Here is the idea of what I want to do:

Here is a description of the strings I have to parse. Approx 100
different string of approx 60 to 100 bytes long.

Each string contain concatened fields. Some are non formatted numbers,
date, time, and many others specific fields.

There is no way to split those string and get a easy to read array. For
each string I have to use mid$ and get each separate fields and format
it in the way it should be. Some fields need basic mathematic
calculation to have a human readable number.

At this point I was thinking to make the C dll for reading purpose, I
mean, pass the raw string to the dll, and it return a parsed array of
all fields (of data type string).

In this VB.NET code I use the string.substring() function to to get
parts of string. Is there a better VB.NET handling for that?

Do you think I could gain speed using a C/C++ dll for this situation?

Thank you for your reply.
Marty

Cor Ligthert wrote:
I am building an application that need high speed of execution. There is
a lot of string parsing that I do in VB.NET.

Do I gain in speed if all that string parsing is made in a dll coded in C
or C++ and added to my VB.NET application?

I would also gain the advantage of portability, but my main concern is
speed of execution.

Can be, however why would it?

There are very fast classes for string handling in VBNet. But there can
always situations which cannot be handled.

Cor

Nov 21 '05 #7
Thanks for the info. I did test to compare my use of the string, and it
get faster with "&" than stringbuilder. But my string process is not as
heavy as yours.

Regards,
Marty

M. Posseth wrote:
Not so long ago i had the folowing task at my job
Write a program that can read a MYSQL dump file of mutiple gigabytes
( the tests were between 2 and 7 gb ) and that wil on the fly convert the
MYSQL data types to SQL server datatypes
and import the data to MS SQL server 2000

well before i used the stringbuilder this took hours ,,,,, after using the
string builder it took minutes

I am really impressed about the string and IO handling of .Net and know that
if you use it at the right way it will be as fast as using a low level
language in a verry very optimized way

M. Posseth


"Marty" <xm******@hotmail.com> wrote in message
news:hrC_d.45890$ZO2.33318@edtnps84...
Hi,

I am building an application that need high speed of execution. There
is a lot of string parsing that I do in VB.NET.

Do I gain in speed if all that string parsing is made in a dll coded in
C or C++ and added to my VB.NET application?

I would also gain the advantage of portability, but my main concern is
speed of execution.

Thank you!

Marty


Nov 21 '05 #8
Marty,
Thanks for the info. I did test to compare my use of the string, and it
get faster with "&" than stringbuilder. But my string process is not as
heavy as yours.


Can you show that code, because I think that most of the ones who are
regular visit this newsgroup will see that.

I that with two constants you can get an almost equal speed.

Cor
Nov 21 '05 #9
Hi Cor,

The stringbuilder is definitely faster for big string concatenation, but
in this example, for each iteration I want to create a stringbuilder
object and concat small amout of string (in Button2 handling).

If I was using only one stringbuilder object and doing
mySB.Append("...") for each iteration, then stringbuilder is the fastest.

What I wanted to do is generate thousands of string as fast as possible.
Is there something I missed with stringbuilder?

Regards,
Martin

'Concat with "&"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim intRepeat As Int32
Dim i As Int32
Dim j As Int32
intRepeat = Convert.ToInt32(tbxRepeat.Text)
tbxStart.Text = Now.Second & ":" & Now.Millisecond
For j = 1 To intRepeat
Dim strTest As String
strTest = vbNullString
strTest &= Chr(2) & _
CStr(j) & _
"999999999" & _
"92.31" & _
"31.00" & _
"blablabla" & _
"999999999" & _
"92.31" & _
"31.00" & _
"blablabla" & _
"999999999" & _
"92.31" & _
"31.00" & _
"blablabla"
Next
tbxStop.Text = Now.Second & ":" & Now.Millisecond
End Sub

'Concat with stringbuilder
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim intRepeat As Int32
Dim j As Int32
intRepeat = Convert.ToInt32(tbxRepeat.Text)
tbxStart.Text = Now.Second & ":" & Now.Millisecond
Dim strTest As String
For j = 1 To intRepeat
Dim sb As New System.Text.StringBuilder
sb.Append(Chr(2))
sb.Append(CStr(j))
sb.Append("999999999")
sb.Append("92.31")
sb.Append("31.00")
sb.Append("blablabla")
sb.Append("999999999")
sb.Append("92.31")
sb.Append("31.00")
sb.Append("blablabla")
sb.Append("999999999")
sb.Append("92.31")
sb.Append("31.00")
sb.Append("blablabla")
strTest = sb.ToString
sb = Nothing
Next
tbxStop.Text = Now.Second & ":" & Now.Millisecond
End Sub

Cor Ligthert wrote:
Marty,

Thanks for the info. I did test to compare my use of the string, and it
get faster with "&" than stringbuilder. But my string process is not as
heavy as yours.

Can you show that code, because I think that most of the ones who are
regular visit this newsgroup will see that.

I that with two constants you can get an almost equal speed.

Cor

Nov 21 '05 #10
Marty,

You are right, with such short strings and constants it is almost the same.

(I have seen this behaviour earlier, it seems that in this case a string is
constructed and than created as string)

Cor
Nov 21 '05 #11
Marty,

For that you think that I did not check it. In this way you will see an
enormous time difference.

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim intRepeat As Integer = CInt(tbxRepeat.Text)
Dim start As Long = Now.Ticks
Dim strTest As String = ""
For i As Integer = 1 To intRepeat
strTest &= Chr(2) & _
CStr(i) & _
"999999999" & _
"92.31" & _
"31.00" & _
"blablabla" & _
"999999999" & _
"92.31" & _
"31.00" & _
"blablabla" & _
"999999999" & _
"92.31" & _
"31.00" & _
"blablabla"
Next
txtConCat.Text = (Now.Ticks - start).ToString
End Sub

'Concat with stringbuilder
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim intRepeat As Integer = CInt(tbxRepeat.Text)
Dim start As Long = Now.Ticks
Dim sb As New System.Text.StringBuilder
For i As Integer = 1 To intRepeat
sb.Append(Chr(2))
sb.Append(CStr(i))
sb.Append("999999999")
sb.Append("92.31")
sb.Append("31.00")
sb.Append("blablabla")
sb.Append("999999999")
sb.Append("92.31")
sb.Append("31.00")
sb.Append("blablabla")
sb.Append("999999999")
sb.Append("92.31")
sb.Append("31.00")
sb.Append("blablabla")
Next
txtStringBuilder.Text = (Now.Ticks - start).ToString
End Sub
Cor
Nov 21 '05 #12
Hi Cor,

You are right, I tried it before, it is pretty fast. It is just that I
need a new string for each iteration. I don't use it as it is, my
algorithm (in small scale) look like a "for", I have to create a
stringbuilder each time, otherwise, I could use a clear method if it was
implemented in the stringbuilder, it could save time instead of doing a
new every time.

Regards,
Marty

Cor Ligthert wrote:
Marty,

For that you think that I did not check it. In this way you will see an
enormous time difference.

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim intRepeat As Integer = CInt(tbxRepeat.Text)
Dim start As Long = Now.Ticks
Dim strTest As String = ""
For i As Integer = 1 To intRepeat
strTest &= Chr(2) & _
CStr(i) & _
"999999999" & _
"92.31" & _
"31.00" & _
"blablabla" & _
"999999999" & _
"92.31" & _
"31.00" & _
"blablabla" & _
"999999999" & _
"92.31" & _
"31.00" & _
"blablabla"
Next
txtConCat.Text = (Now.Ticks - start).ToString
End Sub

'Concat with stringbuilder
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim intRepeat As Integer = CInt(tbxRepeat.Text)
Dim start As Long = Now.Ticks
Dim sb As New System.Text.StringBuilder
For i As Integer = 1 To intRepeat
sb.Append(Chr(2))
sb.Append(CStr(i))
sb.Append("999999999")
sb.Append("92.31")
sb.Append("31.00")
sb.Append("blablabla")
sb.Append("999999999")
sb.Append("92.31")
sb.Append("31.00")
sb.Append("blablabla")
sb.Append("999999999")
sb.Append("92.31")
sb.Append("31.00")
sb.Append("blablabla")
Next
txtStringBuilder.Text = (Now.Ticks - start).ToString
End Sub
Cor

Nov 21 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Yang Li Ke | last post by:
Hi guys, Is it possible to know the internet speed of the visitors with php? Thanx -- Yang
8
by: Rob Ristroph | last post by:
I have tried out PHP 5 for the first time (with assistance from this group -- thanks!). The people I was working with have a site that uses lots of php objects. They are having problems with...
34
by: Jacek Generowicz | last post by:
I have a program in which I make very good use of a memoizer: def memoize(callable): cache = {} def proxy(*args): try: return cache except KeyError: return cache.setdefault(args,...
28
by: Maboroshi | last post by:
Hi I am fairly new to programming but not as such that I am a total beginner From what I understand C and C++ are faster languages than Python. Is this because of Pythons ability to operate on...
7
by: YAZ | last post by:
Hello, I have a dll which do some number crunching. Performances (execution speed) are very important in my application. I use VC6 to compile the DLL. A friend of mine told me that in Visual...
6
by: Ham | last post by:
Yeah, Gotto work with my VB.Net graphic application for days, do any possible type of code optimization, check for unhandled errors and finally come up with sth that can't process 2D graphics and...
6
by: Jassim Rahma | last post by:
I want to detect the internet speed using C# to show the user on what speed he's connecting to internet?
11
by: kyosohma | last post by:
Hi, We use a script here at work that runs whenever someone logs into their machine that logs various bits of information to a database. One of those bits is the CPU's model and speed. While...
4
by: nestle | last post by:
I have DSL with a download speed of 32MB/s and an upload speed of 8MB/s(according to my ISP), and I am using a router. My upload speed is always between 8MB/s and 9MB/s(which is above the max upload...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.