I know that in C++ using +=, -=, ... is faster. I was trying to see if it is faster in VB.NET or not, but I get almost same results. Maybe I'm coding it wrong(I know very very little about .NET)
can someone look at this, maybe it's kinda wrong. But I almost get the same result by using both kind of operators
VB Code:
Module Module1 Sub Main() Console.WriteLine(OldOps()) Console.WriteLine(newOps) Console.ReadLine() End Sub Private Function OldOps() As String Dim i As Long Dim tmp As Byte Dim startTime As Date startTime = Now() For i = 1 To 500000000 tmp = tmp + 1 tmp = tmp - 1 Next Return "OldOps took " & DateDiff(DateInterval.Second, startTime, Now).ToString & " seconds" End Function Private Function newOps() As String Dim i As Long Dim tmp As Byte Dim startTime As Date startTime = Now() For i = 1 To 500000000 tmp += 1 tmp -= 1 Next Return "NewOps took " & DateDiff(DateInterval.Second, startTime, Now).ToString & " seconds" End Function End Module




Reply With Quote