Skip to content

Instantly share code, notes, and snippets.

@rolfbjarne
Created November 22, 2012 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolfbjarne/4130104 to your computer and use it in GitHub Desktop.
Save rolfbjarne/4130104 to your computer and use it in GitHub Desktop.
Module Module1
Sub Main()
Dim i() As Integer = New Integer() {}
Dim watch As New Stopwatch()
Dim aa, bb As Double
For z As Integer = 0 To 10
watch.Restart()
aa = A(i)
watch.Stop()
Console.WriteLine("A: {0} {1}", aa, watch.ElapsedMilliseconds)
watch.Restart()
bb = B(i)
watch.Stop()
Console.WriteLine("B: {0} {1}", bb, watch.ElapsedMilliseconds)
Next
Console.ReadLine()
End Sub
Const iterations As Integer = 136000000
Function A(i() As Integer) As Double
Dim c As Double
For j = 0 To iterations
c += i.Length
Next
Return c
End Function
Function B(i() As Integer) As Double
Dim c As Double
For j = 0 To iterations
c += i.GetLength(0)
Next
Return c
End Function
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment