That is not a fair test though for at least 3 reasons I can see.
This is a less biased benchmark...
VB Code:
Sub Main() Dim t As Integer Dim temp As String Dim i, j, k As Integer For k = 1 To 5 t = Environment.TickCount j = 0 For i = 1 To 1000000000 WasteOfTime() Next i t = Environment.TickCount - t temp = "Run " & k & ": For: " & t & "ms" '##### t = Environment.TickCount j = 0 Do Until j = 1000000000 j += 1 WasteOfTime() Loop t = Environment.TickCount - t temp &= ", Do: " & t & "ms" Console.WriteLine(temp) Next k Console.ReadLine() End Sub Public Sub WasteOfTime() Dim s As String = "A"c s = Nothing End Sub
NOTE: I haven't got any decent timer code on me at the moment so feel free to replace the Tickcount with something more accurate.
PS (The wasteoftime method is just to make sure the compiler doesn't discard pointless loops, it also gives the for loop something to do)




Reply With Quote