Created
November 22, 2012 09:06
-
-
Save rolfbjarne/4130104 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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