|
-
Aug 10th, 2002, 06:13 AM
#1
Thread Starter
Hyperactive Member
Bugz: VB6 vs VB.NET comparison
Hi Bugz.
Here's some code so we can test the relative speeds of VB6 and VB.NET. Can you run it on VB6 and VB.NET and let me know the results (as well as CPU speeds of each machine)?
Just for reference, it ran in 13.5 seconds on my computer: VB6, AMD XP1600+.
Feel free to change any of the tests if you want.
Make sure to change the Long/Double datatypes in VB.NET if needed - I seem to remember Microsoft changed Long to Integer or something. Just as long as the test is fair...
VB Code:
Declare Function GetTickCount Lib "kernel32.dll" () As Long
Sub Main()
'Program to test relative speed of VB6 vs VB.NET
'Tests mathematical operations
'Coded 10.8.02
Dim x As Long
Dim z As Double
Dim start As Long
MsgBox "Press OK to begin mathematical operations. Tests should take <1 minute."
start = GetTickCount
'Basic operations, integer & floating point
For x = 0 To 10000000
z = 17 + 56 / (9 * 263) - 78 / (2.2 * 9)
Next
'Rnd
For x = 0 To 1000000
z = Rnd
Next
'Trig functions
For x = 0 To 10000000
z = Sin(23.5687)
z = Cos(23.5687)
z = Tan(23.5687)
z = Atn(23.5687)
Next
'Sqr
For x = 0 To 10000000
z = Sqr(2315.126)
Next
'Exp & log
For x = 0 To 10000000
z = Exp(22.561)
z = Log(22.561)
Next x
MsgBox (GetTickCount() - start) / 1000 & " seconds elapsed."
End Sub
There are 10 types of people in the world - those that understand binary, and those that don't.
-
Aug 10th, 2002, 08:44 AM
#2
Fanatic Member
lol haven't used VB much lately. so what i am suppose to do, copy the code into a module? Then I remember you have to change something to make it run from the module (too bad i forgot what)
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Aug 10th, 2002, 08:48 AM
#3
Fanatic Member
ok, i got it to work and it says 30-31 seconds on VB6, running on Pentium III 666mhz,383.0 RAM, and Windows ME.
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Aug 10th, 2002, 08:49 AM
#4
Thread Starter
Hyperactive Member
Boot up VB.
Click Start New Project or New Exe option.
Add a new module.
Copy & paste the code in.
Click compile.
Run the proggy.
Repeat for .NET.
There are 10 types of people in the world - those that understand binary, and those that don't.
-
Aug 10th, 2002, 08:52 AM
#5
Fanatic Member
i started from standard exe so i have an extra step
in VB6 at least, gotta go to Project->Properties->Start-up->Sub Main() (instead of Form 1)
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Aug 10th, 2002, 08:53 AM
#6
Thread Starter
Hyperactive Member
Oh cool, have you got hte .NET machine handy?
There are 10 types of people in the world - those that understand binary, and those that don't.
-
Aug 10th, 2002, 08:53 AM
#7
Fanatic Member
gimme a sec, .NET loads slow
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Aug 10th, 2002, 08:55 AM
#8
Thread Starter
Hyperactive Member
There are 10 types of people in the world - those that understand binary, and those that don't.
-
Aug 10th, 2002, 08:58 AM
#9
Fanatic Member
the stuff is a little bit different. i gotta figure out how first (like it has a windows application instead of a standard exe)
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Aug 10th, 2002, 09:06 AM
#10
Fanatic Member
VB .NET, Windows 2k Server, Pentium III 1000 mhz, 253MB RAM. now the tick says 171798702.075 seconds but i can guarentee that it ran for less than 2 seconds.
i think it is the same speed as VC++ as everything is in .NET framework now (not sure what that means myself)
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Aug 10th, 2002, 09:08 AM
#11
Fanatic Member
have to make some code modifications/adjustments also i ditched the module since i don't know how to make it work in .NET (highlighted the change):
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Name = "Form1"
Me.Text = "Form1"
End Sub
#End Region
Declare Function GetTickCount Lib "kernel32.dll" () As Long
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Program to test relative speed of VB6 vs VB.NET
'Tests mathematical operations
'Coded 10.8.02
Dim x As Long
Dim z As Double
Dim start As Long
MessageBox.Show("Press OK to begin mathematical operations. Tests should take <1 minute.")
start = GetTickCount
'Basic operations, integer & floating point
For x = 0 To 10000000
z = 17 + 56 / (9 * 263) - 78 / (2.2 * 9)
Next
'Rnd
For x = 0 To 1000000
z = Rnd()
Next
'Trig functions
For x = 0 To 10000000
z = System.Math.Sin(23.5687)
z = System.Math.Cos(23.5687)
z = System.Math.Tan(23.5687)
z = System.Math.Atan(23.5687)
Next
'Sqr
For x = 0 To 10000000
z = System.Math.Sqrt(2315.126)
Next
'Exp & log
For x = 0 To 10000000
z = System.Math.Exp(22.561)
z = System.Math.Log(22.561)
Next x
MessageBox.Show((GetTickCount() - start) / 1000 & " seconds elapsed.")
End Sub
End Class
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Aug 10th, 2002, 09:13 AM
#12
Fanatic Member
make note that VB .NET executables needs .NET framework to work.
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Aug 10th, 2002, 03:50 PM
#13
Thread Starter
Hyperactive Member
Oh nice one bugz. So we can agree that .NET is faster!
There are 10 types of people in the world - those that understand binary, and those that don't.
-
Aug 10th, 2002, 09:25 PM
#14
yay gay
is as fast as machine code ( assembly ) or vc++ as well as any .NET language cuz they're all compiled using the CRL
-
Aug 13th, 2002, 06:19 AM
#15
Fanatic Member
All .NET is compiled to MSIL, then compiled to platform-specific code by the JIT upon its first execution.
So, AFAIK all .NET languages should run at the same speed (assuming the code is the same), and .NET programs should run a lot faster after the first execution, depending on how much there is to compile
-C
-
Aug 13th, 2002, 08:18 AM
#16
Lively Member
The reason (not the only one...) that VB.NET is much faster then VB6 in this case is that the compiler is "smarter" in .NET.
In this example, the compiler knows the result without even entering the For...next. (in most of the cases)
Example:
'Sqr
For x = 0 To 10000000
z = System.Math.Sqrt(2315.126)
Next
The result (z) will be same both the first time and the 10000000th time and the compiler can see that without going into the loop.
...or what do you think?
________________________
Fredrik Klarqvist
-
Aug 13th, 2002, 10:49 AM
#17
Fanatic Member
i don't think it works that way -- rarely does anyone do something like that. VB .NET does have a JIT debugger (Just In Time) which i think thats what it is called, that is unavailable to all other .NET languages. what it does is compiling the code as you type them and catch any syntax errors and underlines them -- just as Word highlights your grammar errors (right click will probably get the correct fix for you). all the other langs you have to run it in order to find out whats wrong.
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Aug 13th, 2002, 05:47 PM
#18
Thread Starter
Hyperactive Member
hi bugz. You're right in that VB has a JIT compiler but it's not the thing that catches the syntax errors in design time. The JIT compiler does stuff like, say, allow the program to run when you change the next statement (at run time) when program execution is broken.
There are 10 types of people in the world - those that understand binary, and those that don't.
-
Aug 13th, 2002, 06:11 PM
#19
Fanatic Member
guess this feature is called something else.
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Aug 20th, 2002, 09:45 PM
#20
Fanatic Member
the feature is called autocomplete if anyone is interested
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Aug 21st, 2002, 01:13 PM
#21
Hyperactive Member
If you guys are interested
P IV 1.8 256mb DDR Win XP
VB 6 = 20.469 seconds
VB.NET = 13.312 seconds
If you use the open project function on a vb6 project then it will convert it to vb.NET for you.
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
|