|
-
Sep 5th, 2023, 05:24 AM
#11
Re: TwinBasic
 Originally Posted by Schmidt
There's something wrong with the VB6.Col For Each test...
...which traditionally works pretty fast (as the test below shows, when enumerating 1Mio entries)
Code:
Private Sub Form_Click()
Cls
Dim i As Long, Col As New Collection, T, V
T = Timer: i = 0
For i = 1 To 10 ^ 6
Col.Add i
Next
Print "Col Add:", CLng((Timer - T) * 1000) & "msec"
T = Timer: i = 0
For Each V In Col
i = i + 1: If i <> V Then Stop
Next
Print "For Each:", CLng((Timer - T) * 1000) & "msec"
End Sub
Olaf
Well spotted. Indeed, there was a copy-paste bug in the for-each test causing the results to also be affected by the cost of forward-index retrieval. After fixing the bug, the VB6 and tB versions of that test now look to perform similarly.
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
|