VB5 strings are slow 
Author Message
 VB5 strings are slow

Hi-

  Below is a simple sub I've used for 10 years to sort a variable length
string array.  Well, in VB5 it's at least 5 to 8 times slower than in
VB4/16!  In both cases I ran from .EXE's.
For 25,000 elements VB4/16 took 3 seconds and VB5 took 15 seconds
For 45,000 elements VB4/16 took 7 seconds and VB5 took 57 seconds

  I'm sure I can find a better sort routine...but this scares me.  What
else is slower in VB5?!  If anyone knows what all got slower in VB5 and
why, I'd love to hear it...some string-intensive parts of my app are
running much slower now that I switched to 32-bit VB5.

Thanks,

Sub SORTSTRING(SVEC(), L)
'
' Sort the L elements of the string vector SVEC() into increasing order.
'
' Variables starting with S are strings, starting with L are longs

           LM = L
SORTSL1:   LJ = 1: LM = Int(LM / 2)
           If LM = 0 Then Exit Sub Else LI = LJ
SORTSL2:   If SVEC(LI) <= SVEC(LI + LM) Then GoTo SORTSL3
           SQ = SVEC(LI): SVEC(LI) = SVEC(LI + LM): SVEC(LI + LM) = SQ
           LI = LI - LM: If LI >= 1 Then GoTo SORTSL2
SORTSL3:   LJ = LJ + 1
           If LJ > L - LM Then GoTo SORTSL1 Else LI = LJ: GoTo SORTSL2
End Sub



Sat, 18 Nov 2000 03:00:00 GMT  
 VB5 strings are slow

VB 4/16 used ANSI characters.
VB 4/32 and VB5 use Unicode characters. This means twice as much data to
shuffle.

The code is rather opaque. I thought Goto had been relegated to the dustbin
years ago. (Apart from error handling that is.)

Regards,
Simon Jones
PC Pro Magazine



Sun, 19 Nov 2000 03:00:00 GMT  
 VB5 strings are slow

Simon

Haven't you found yourself in a position where you would love to use a
GoTo? Somewhere in the middle of a nested If? Have you gritted your
teeth and either introduced repeated code (because it's only a little
bit) or invented a procedure to help you out? All because someone,
somewhere said GoTo's were wrong.

Well, I think they are elegant, concise, documentarily sound (as long as
the label name is good) and are hard to beat in some situations. I don't
happen to use them very often, but I certainly don't think twice about
it if the situation arises.

Regards
{*filter*}


Quote:
>VB 4/16 used ANSI characters.
>VB 4/32 and VB5 use Unicode characters. This means twice as much data
to
>shuffle.

>The code is rather opaque. I thought Goto had been relegated to the
dustbin
>years ago. (Apart from error handling that is.)

>Regards,
>Simon Jones
>PC Pro Magazine



Sun, 19 Nov 2000 03:00:00 GMT  
 VB5 strings are slow

No, I've never even been tempted to use Goto except for error handling.

Regards,
Simon Jones
PC Pro Magazine



Sun, 19 Nov 2000 03:00:00 GMT  
 VB5 strings are slow

I have found that well structured code doesn't need gotos except for
handling errors.  If your normal code path requires a goto, you need to
rethink the program flow logic because you're missing something in your
control statements.

Mike Ober.

Quote:

>No, I've never even been tempted to use Goto except for error handling.

>Regards,
>Simon Jones
>PC Pro Magazine



Sun, 19 Nov 2000 03:00:00 GMT  
 VB5 strings are slow

Hi Brad,

I haven't got an answer for you, but I did notice a major speed difference
in my applications due to upgrading from VB3 to VB5.  It could be something
to do with Microsoft upgrading to a 32 bit edition of VB.

I can't wait for customers and clients to upgrade to newer systems so our
software doesn't use the slow processing glitch anymore.  I've been tweaking
my routines but still seem to have speed problems on older computer.

Good one Microsoft!
    Travis Penglase.



Mon, 20 Nov 2000 03:00:00 GMT  
 VB5 strings are slow

Brad -
    You say that the variables are Strings and Longs, but are you sure?  VB
now defaults to variants, which can be slow in some situations.  To be
certain, use Option Explicit and explicitly Dim every variable by type.  I'd
be a little surprised to find that VB5 were that much slower unless something
else was going on (like variants for longs, etc).

    Also, VB5 defaults to text comparison, where VB3 defaulted to binary
comparison.  Specify Option Compare Binary to get a better comparison between
the two platforms.  VB5's Compare Text option uses international case
shifting and collating with Unicode, so it can be painful at times.

    GoTo is frowned upon not just for style but because code using it will
"fall out" of the optimizer.  Your code could easily be rewritten without
GoTo, and it would optimize better.

    Applying all the above should get your performance back to VB3 levels or
better.

   If you're interested in something that could seriously improve your
performance, take a look at my company's Stamina product.  Among its 330+
routines (all written in 32-bit ASM) are several sort routines based on
Quicksort.  My guess is it could do your 45000 elements in less than a
second.

--
     Jim Mack
     MicroDexterity, Inc
     PO Box 5372
     Plymouth, MI  48170-5372

     http://www.microdexterity.com



     Fax:  +1 734-453-8942

Quote:

>   Below is a simple sub I've used for 10 years to sort a variable length
> string array.  Well, in VB5 it's at least 5 to 8 times slower than in
> VB4/16!  In both cases I ran from .EXE's.
> For 25,000 elements VB4/16 took 3 seconds and VB5 took 15 seconds
> For 45,000 elements VB4/16 took 7 seconds and VB5 took 57 seconds

>   I'm sure I can find a better sort routine...but this scares me.  What
> else is slower in VB5?!  If anyone knows what all got slower in VB5 and
> why, I'd love to hear it...some string-intensive parts of my app are
> running much slower now that I switched to 32-bit VB5.

> Thanks,

> Sub SORTSTRING(SVEC(), L)
> '
> ' Sort the L elements of the string vector SVEC() into increasing order.
> '
> ' Variables starting with S are strings, starting with L are longs

>            LM = L
> SORTSL1:   LJ = 1: LM = Int(LM / 2)
>            If LM = 0 Then Exit Sub Else LI = LJ
> SORTSL2:   If SVEC(LI) <= SVEC(LI + LM) Then GoTo SORTSL3
>            SQ = SVEC(LI): SVEC(LI) = SVEC(LI + LM): SVEC(LI + LM) = SQ
>            LI = LI - LM: If LI >= 1 Then GoTo SORTSL2
> SORTSL3:   LJ = LJ + 1
>            If LJ > L - LM Then GoTo SORTSL1 Else LI = LJ: GoTo SORTSL2
> End Sub



Tue, 21 Nov 2000 03:00:00 GMT  
 VB5 strings are slow

I beg to differ. If GoTo's were wrong then why is visdata full of them?
Microsoft would not use them in there main example if they were a bad idea.

Quote:

>I have found that well structured code doesn't need gotos except for
>handling errors.  If your normal code path requires a goto, you need to
>rethink the program flow logic because you're missing something in your
>control statements.

>Mike Ober.


>>No, I've never even been tempted to use Goto except for error handling.

>>Regards,
>>Simon Jones
>>PC Pro Magazine



Sun, 03 Dec 2000 03:00:00 GMT  
 VB5 strings are slow

I noticed that there are alot of "Compatability" components that are used
when you upgrade a project. If you manually upgrade all of your references
and components, you will see better performance.

Quote:

>Hi Brad,

>I haven't got an answer for you, but I did notice a major speed difference
>in my applications due to upgrading from VB3 to VB5.  It could be something
>to do with Microsoft upgrading to a 32 bit edition of VB.

>I can't wait for customers and clients to upgrade to newer systems so our
>software doesn't use the slow processing glitch anymore.  I've been
tweaking
>my routines but still seem to have speed problems on older computer.

>Good one Microsoft!
>    Travis Penglase.



Sun, 03 Dec 2000 03:00:00 GMT  
 VB5 strings are slow

Microsoft's sample code is OFTEN horrible.
Read and understand it and then re-write any examples you see from
Microsoft.

Regards,
Simon Jones
PC Pro Magazine



Mon, 04 Dec 2000 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. VB5 slow down with string arrays

2. Why am I so Slow

3. Slow, slow, slow search on VB6, ADO and SS7

4. VB4 is slow..slow....slow

5. Insert into SQL Server slow, slow, slow...

6. Slow Searching Text File / String

7. Concatenate Large Strings is awful slow

8. VB strings are slow!

9. VB strings are slow!

10. Repeated string concat too slow -- help

11. Slow string searches in VB4

12. VB strings are slow!

 

 
Powered by phpBB® Forum Software