Results 1 to 21 of 21

Thread: Bugz: VB6 vs VB.NET comparison

  1. #1

    Thread Starter
    Hyperactive Member DavidHooper's Avatar
    Join Date
    Apr 2001
    Posts
    357

    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:
    1. Declare Function GetTickCount Lib "kernel32.dll" () As Long
    2. Sub Main()
    3. 'Program to test relative speed of VB6 vs VB.NET
    4. 'Tests mathematical operations
    5. 'Coded 10.8.02
    6.  
    7. Dim x As Long
    8. Dim z As Double
    9. Dim start As Long
    10.  
    11. MsgBox "Press OK to begin mathematical operations. Tests should take <1 minute."
    12.  
    13. start = GetTickCount
    14.  
    15. 'Basic operations, integer & floating point
    16. For x = 0 To 10000000
    17.     z = 17 + 56 / (9 * 263) - 78 / (2.2 * 9)
    18. Next
    19.  
    20. 'Rnd
    21. For x = 0 To 1000000
    22.     z = Rnd
    23. Next
    24.  
    25. 'Trig functions
    26. For x = 0 To 10000000
    27.     z = Sin(23.5687)
    28.     z = Cos(23.5687)
    29.     z = Tan(23.5687)
    30.     z = Atn(23.5687)
    31. Next
    32.  
    33. 'Sqr
    34. For x = 0 To 10000000
    35.     z = Sqr(2315.126)
    36. Next
    37.  
    38. 'Exp & log
    39. For x = 0 To 10000000
    40.     z = Exp(22.561)
    41.     z = Log(22.561)
    42. Next x
    43.  
    44. MsgBox (GetTickCount() - start) / 1000 & " seconds elapsed."
    45. End Sub
    There are 10 types of people in the world - those that understand binary, and those that don't.

  2. #2
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    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)!

  3. #3
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    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)!

  4. #4

    Thread Starter
    Hyperactive Member DavidHooper's Avatar
    Join Date
    Apr 2001
    Posts
    357
    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.

  5. #5
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    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)!

  6. #6

    Thread Starter
    Hyperactive Member DavidHooper's Avatar
    Join Date
    Apr 2001
    Posts
    357
    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.

  7. #7
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    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)!

  8. #8

    Thread Starter
    Hyperactive Member DavidHooper's Avatar
    Join Date
    Apr 2001
    Posts
    357
    Chuckle.
    There are 10 types of people in the world - those that understand binary, and those that don't.

  9. #9
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    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)!

  10. #10
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    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)!

  11. #11
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    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)!

  12. #12
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    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)!

  13. #13

    Thread Starter
    Hyperactive Member DavidHooper's Avatar
    Join Date
    Apr 2001
    Posts
    357
    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.

  14. #14
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    is as fast as machine code ( assembly ) or vc++ as well as any .NET language cuz they're all compiled using the CRL

  15. #15
    Fanatic Member siyan's Avatar
    Join Date
    Jul 2001
    Location
    GOOOAAAAALLLLL!!!!!
    Posts
    869
    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

  16. #16
    Lively Member
    Join Date
    May 2001
    Location
    Falkenberg, Sweden
    Posts
    76
    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

  17. #17
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    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)!

  18. #18

    Thread Starter
    Hyperactive Member DavidHooper's Avatar
    Join Date
    Apr 2001
    Posts
    357
    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.

  19. #19
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    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)!

  20. #20
    Fanatic Member bugzpodder's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    787
    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)!

  21. #21
    Hyperactive Member marnitzg's Avatar
    Join Date
    Oct 2000
    Location
    South Africa
    Posts
    372
    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
  •  



Click Here to Expand Forum to Full Width