|
-
Sep 12th, 2002, 06:40 AM
#1
SPEED ! Lengthy but VERY interesting facts.
I couldnt find an answer to my question on the forums so I thought I would investigate myself.
In VB6 you always called a function and passed it the variables you want to work with.
e.g Split( MyString, ",")
In .Net you can now do this instead
MyString.Split(","c)
which passes your arguments straight to the instance class.
Now I guess this was faster then the VB6 way and wanted to know by how much. I was amazed at the difference.
For all you programmers who have just converted your apps from VB6 to .Net, this can make a massive difference to speed.
Change your Lefts, Rights, Splits, Instr, InstrRev etc to use the class directly.
Also replace any string concats with the StringBuilder class which is also amazingly quick. I have shaved seconds off compression functions with it. (70 meg in less then 1 second!)
My current project is building a server application, so has to be at top speed all the time, so any other tips would be gratefull !!
----------------
If you want to see for yourself, run the code below, but bring up your dissasembly window (Ctrl+Alt+D) and see how many calls each function makes. The first function is about 30, the second goes on for hundereds.
VB Code:
Dim strMessageString As String = "ABCD,EFGHIJ,KLMNOPQ,RSTUVW,XYZ"
Dim strString() As String
strString = strMessageString.Split(","c)
strString = Split(strMessageString, ",")
-
Sep 12th, 2002, 07:48 AM
#2
Frenzied Member
ofCourse
You also should take into accont that vb compiles into a solid object orianted language as fast as c++ now and that in it self is part of the reason for the new javascript asc aproch to strings and having a math object too.... hmm could it have anything to do with the great move to internet developer and having a job being one and the same.....
Magiaus
If I helped give me some points.
-
Sep 12th, 2002, 07:50 AM
#3
Frenzied Member
should ther be a comma between "," and c or is that some new concatination i don't know about
Magiaus
If I helped give me some points.
-
Sep 12th, 2002, 08:02 AM
#4
Nope, the c needs to be there.
Because I am using a constant "," you can specify its type, putting the c after makes it a type char, also like puting 34i or 25d which is integer and decimal to allow you to pass straight to functions without having to declare or convert them.
-
Sep 12th, 2002, 08:06 AM
#5
Frenzied Member
ahh i see
$, &, %, #, @... have new .net brother as do CStr() and (char)int castInC
Magiaus
If I helped give me some points.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|