Results 1 to 5 of 5

Thread: SPEED ! Lengthy but VERY interesting facts.

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    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:
    1. Dim strMessageString As String = "ABCD,EFGHIJ,KLMNOPQ,RSTUVW,XYZ"
    2.         Dim strString() As String
    3.  
    4.  
    5.         strString = strMessageString.Split(","c)
    6.  
    7.         strString = Split(strMessageString, ",")

  2. #2
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    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.

  3. #3
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    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.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    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.

  5. #5
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    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
  •  



Click Here to Expand Forum to Full Width