|
-
Apr 14th, 2002, 10:32 PM
#1
Assignment operators
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
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Apr 14th, 2002, 11:09 PM
#2
Frenzied Member
I dont think you'll see any speed increase from those operators.
Dont gain the world and lose your soul
-
Apr 14th, 2002, 11:11 PM
#3
yeah that's what happened. I though maybe that's not a good test
But I think i C++ there is a difference in speed
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Apr 15th, 2002, 05:48 AM
#4
Frenzied Member
i++..?
in my post woooo hooooo i posted on app i tried to use ++ in this app and it would not compile. Option Strict is On.
Anyone know whats up with that..? i asume that it has to be done i += 1
Magiaus
If I helped give me some points.
-
Apr 15th, 2002, 10:40 AM
#5
Frenzied Member
I dont think ++ is suported in VB with or without option strict.
Dont gain the world and lose your soul
-
Apr 15th, 2002, 08:19 PM
#6
I think in C++ the speed increase is because (correct me if I'm wrong!) it complies to ASM as
Code:
INC whatever
instead of
ADD whatever, 1
since VB compiles to the MSIL, I don't think you'll see a speed increase.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
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
|