Benchmark test - VB6/VC6/Delphi6/Java

Discussion in 'Programming General' started by Govind, Mar 15, 2008.

Benchmark test - VB6/VC6/Delphi6/Java
  1. Unread #1 - Mar 15, 2008 at 6:01 PM
  2. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Benchmark test - VB6/VC6/Delphi6/Java

    I have posted inaccurate benchmarks in the past. This here is a valid one.VC++6, VB6, and Delphi6 are running all program with equivalent algorithms to populate a 1000 element array with random elements 1000 times. (Byte and char types are equivalent in terms of size).

    Here is the code I used for the Visual C++ 6 Benchmark:

    Code:
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    #include <ctime>
    #include <cstdlib>
    #include <iostream>
    using namespace std;
    int main(int argc, char* argv[])
    {
        char data[1000];
        DWORD dwStart = GetTickCount();
        for(int i = 0; i < 1000; i++)
        {
            for(int j = 0; j < 1000; j++)
            {
                data[j] = (char)rand()%100;
            }
        } 
        DWORD dwEnd = GetTickCount();
        cout << "Took " << (dwEnd)-(dwStart) << " milliseconds to complete." << endl;
        return 0;
    }
    Here is the code I used for the Visual Basic 6 Benchmark:

    Code:
    Private Declare Function GetTickCount Lib "kernel32" () As Long
    
    Private Sub Command1_Click()
    Dim Start As Long
    Start = GetTickCount()
    Dim arr1(1000) As Byte
    Dim i As Integer
    Dim j As Integer
    For i = 1 To 1000
        For j = 1 To 1000
            arr1(j) = Rnd Mod 100
        Next j
    Next i
    Dim EndTime As Long
    EndTime = GetTickCount()
    MsgBox "That took " & Str(EndTime - Start) & " milliseconds to complete."
    End Sub
    And the Borland Delphi 6 equivalent:
    Code:
    program Project2;
    
    {$APPTYPE CONSOLE}
    
    uses
      SysUtils, Windows;
    var
    i,j,start,endtime:Longint;
    data: array[1..1000] of Byte;
    begin
      { TODO -oUser -cConsole Main : Insert code here }
      start := GetTickCount();
      for i := 1 to 1000 do
      begin
            for j := 1 to 1000 do
            begin
                    data[j] := Random(32767) mod 100;
                    // 32767 is the same as RAND_MAX in VC++
            end;
      end;
      endtime := GetTickCount();
      WriteLn('That took ' + IntToStr(endtime-start) + ' milliseconds to finish.');
    end.
    Java source (thanks Cheese Police):
    Code:
    public class Benchmark
    {
        public static void main(String[] args)
        {
            byte[] data = new byte[1000];
            long start = System.currentTimeMillis();
            for (int i = 0; i < 1000; i++)
            {
                for (int j = 0; j < 1000; j++)
                {
                    data[j] = (byte) (Math.random() * 256);
                }    
            }
            long end = System.currentTimeMillis();
            System.out.println((end - start) + " ms");
        }
    
    }
    Output:

    VB6:
    157 milliseconds
    156 milliseconds
    141 milliseconds
    141 milliseconds
    140 milliseconds

    VC6:
    31 milliseconds
    16 milliseconds
    31 milliseconds
    15 milliseconds
    31 milliseconds

    BD6:
    16 milliseconds
    31 milliseconds
    31 milliseconds
    31 milliseconds
    31 milliseconds

    Java:
    125 ms
    94 ms
    94 ms
    94 ms
    94 ms

    Averages: VB6 - takes 147 milliseconds to fill a 1000 element array 1000 times
    VC6 - takes 24.8 milliseconds to fill a 1000 element array 1000 times
    BD6 - takes 28 milliseconds to fill a 1000 element array 1000 times
    Java - takes 100.2 milliseconds to fill a 1000 element array 1000 times

    C++ and Delphi are pretty evenly matched, Java is only slow because of it being bytecode, although, it's obvious here who the clear loser is in terms of speed. The algorithm is exactly the same, yet VB takes significantly longer to run it.
     
  3. Unread #2 - Mar 15, 2008 at 7:32 PM
  4. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Benchmark test - VB6/VC6/Delphi6/Java

    For VB, did you compile the program and run the .exe or simply run it through the IDE? Compiling the program makes it run "faster".

    I don't use any of these, I use code::blocks and C/C++, maybe MSVC# if I need something fast.
     
  5. Unread #3 - Mar 15, 2008 at 7:33 PM
  6. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Benchmark test - VB6/VC6/Delphi6/Java

    I actually compiled the VB project before running it. I know what I'm doing lol >_>
     
  7. Unread #4 - Mar 15, 2008 at 8:05 PM
  8. CFJ0
    Joined:
    Apr 22, 2005
    Posts:
    188
    Referrals:
    0
    Sythe Gold:
    0

    CFJ0 Active Member

    Benchmark test - VB6/VC6/Delphi6/Java

    Code:
    program Project2;
    
    uses
     Windows;
    
    function IntToStr(i: Integer): String;
    begin
     Str(i, Result);
    end;
    
    var
     I, J, Start, EndTime: LongInt;
     Data: array[1..1000] of Byte;
    begin
     Start := GetTickCount();
     for I := 1 to 1000 do for J := 1 to 1000 do data[J] := Random(32767) mod 100;
     EndTime := GetTickCount();
     MessageBox(0, PChar('That took ' + IntToStr(EndTime-Start) + ' milliseconds to finish.'), nil, 0);
    end.
    For me this does:
    15 milliseconds
    15 milliseconds
    16 milliseconds
    31 milliseconds
    15 milliseconds

    Depends on luck... C++ & Delphi are the same speed for this thing xD.
    Note: This is on Delphi 2007.
     
  9. Unread #5 - Mar 15, 2008 at 8:17 PM
  10. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    Benchmark test - VB6/VC6/Delphi6/Java

    Here is a C# 3.0 benchmark code:
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Benchmark
    {
        class Program
        {
            [System.Runtime.InteropServices.DllImport("kernel32")]
            static extern Int32 GetTickCount();
            static Random rnd = new Random();
    
            static void Main(string[] args)
            {
                do
                {
                    Console.WriteLine(Bench());
                    Console.ReadKey();
                } while (true);
            }
    
            static Int32 Bench()
            {
                var data = new byte[1000];
                var start = GetTickCount();
                for (var i = 0; i < 1000; i++)
                    for (var j = 0; j < 1000; j++)
                        data[j] = (byte)(rnd.Next() % 100);
                var end = GetTickCount();
                return (end - start);
            }
        }
    }
    My results were:
    47
    31
    46
    31
    31

    The loop is just so I dont have to restart the application each time.
     
  11. Unread #6 - Mar 15, 2008 at 8:46 PM
  12. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Benchmark test - VB6/VC6/Delphi6/Java

    Yes, I did notice that the speed between Delphi/VC++ is usually quite close.

    Nice, I would've actually expected .NET results to be close to Java's as .NET is also bytecode - but your computer is probably better than my P.O.S. :p
     
  13. Unread #7 - Mar 16, 2008 at 6:25 AM
  14. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Benchmark test - VB6/VC6/Delphi6/Java

    Here's vb.NET 2005
    Code:
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim Start As Long
            Start = System.Environment.TickCount
            Dim arr1(1000) As Byte
            Dim i As Integer
            Dim j As Integer
            For i = 1 To 1000
                For j = 1 To 1000
                    arr1(j) = Rnd() Mod 100
                Next j
            Next i
            Dim EndTime As Long
            EndTime = System.Environment.TickCount
            MsgBox("That took " & Str(EndTime - Start) & " milliseconds to complete.")
        End Sub
    End Class
    
    Results:
    265
    265
    234
    250
    266
     
  15. Unread #8 - Mar 16, 2008 at 9:02 AM
  16. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    Benchmark test - VB6/VC6/Delphi6/Java

    I compiled your C++ source with Dev-CPP and came up with an average of 47 milliseconds, considerably worse.
     
  17. Unread #9 - Mar 16, 2008 at 9:17 AM
  18. LeetScape
    Joined:
    May 27, 2007
    Posts:
    126
    Referrals:
    0
    Sythe Gold:
    1

    LeetScape Active Member

    Benchmark test - VB6/VC6/Delphi6/Java

    Surely these aren't reliable? I mean, after all it depends on the CPU speed too so someone with a not-so-good computer would have even worse results.
     
  19. Unread #10 - Mar 16, 2008 at 11:15 AM
  20. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Benchmark test - VB6/VC6/Delphi6/Java

    All the tests that I did were run on the same computer.
     
  21. Unread #11 - Mar 16, 2008 at 11:19 AM
  22. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Benchmark test - VB6/VC6/Delphi6/Java

    What speed is your CPU?
     
  23. Unread #12 - Mar 16, 2008 at 2:03 PM
  24. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    Benchmark test - VB6/VC6/Delphi6/Java

    Can you post your CPU speed too, I wouldn't think that VC++ should be that much faster than Dev-CPP.

    I used an Intel Cored Duo T7200 @ 2.00GHz.
     
  25. Unread #13 - Mar 16, 2008 at 3:27 PM
  26. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Benchmark test - VB6/VC6/Delphi6/Java

    I have an emachines running a Pentium IV @ 1.99 GHz (not overclocked, not dual core) with 384 MB RAM. Given that, my computer should be a lot slower than yours.
     
  27. Unread #14 - Mar 16, 2008 at 3:49 PM
  28. cazax
    Joined:
    Nov 13, 2007
    Posts:
    457
    Referrals:
    0
    Sythe Gold:
    0

    cazax Forum Addict

    Benchmark test - VB6/VC6/Delphi6/Java

    omg i tried this in SCAR:
    Code:
    program New;
    var
      i, time, finishtime, k : Integer;
      Data : array[0..1000] of byte;
    begin
      time := GetSystemTime;
      for i:=0 to High(Data) do
      begin
        for k:= 0 to High(Data) do
        begin
          Data[k] := random(32767) mod 100;
        end;
      end;
      finishtime := GetSystemTime;
      writeln('That took '+inttostr(finishtime-time)+' milliseconds to finish.');
    end.
    That took 24687 milliseconds to finish.

    im not lucky.
     
  29. Unread #15 - Mar 16, 2008 at 6:24 PM
  30. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Benchmark test - VB6/VC6/Delphi6/Java

    No, use the GetTickCount API - enable API calls then declare it from kernel32.dll.
     
  31. Unread #16 - Mar 16, 2008 at 7:34 PM
  32. cazax
    Joined:
    Nov 13, 2007
    Posts:
    457
    Referrals:
    0
    Sythe Gold:
    0

    cazax Forum Addict

    Benchmark test - VB6/VC6/Delphi6/Java

    kernel32.dll? btw in SCAR there isnt any plugin called kernel.
     
  33. Unread #17 - Mar 16, 2008 at 8:05 PM
  34. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Benchmark test - VB6/VC6/Delphi6/Java

    No, learn how to call Windows APIs through SCAR -.- Try dlltest.scar in the Test folder.
     
  35. Unread #18 - Mar 17, 2008 at 4:43 PM
  36. cazax
    Joined:
    Nov 13, 2007
    Posts:
    457
    Referrals:
    0
    Sythe Gold:
    0

    cazax Forum Addict

    Benchmark test - VB6/VC6/Delphi6/Java

    k, and whats the difference between GetSystemTime and GetTicketCount?
     
  37. Unread #19 - Mar 18, 2008 at 1:56 AM
  38. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Benchmark test - VB6/VC6/Delphi6/Java

    I have an Intel Celeron CPU 2.80 GHz with 1.46 GB of RAM.

    Why do you ask?
     
  39. Unread #20 - Mar 18, 2008 at 8:06 AM
  40. Govind
    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Benchmark test - VB6/VC6/Delphi6/Java

    Because test results will differ on CPU's with varying speed.
     
< Combo box addressing need help! | My First Java Program >

Users viewing this thread
1 guest


 
 
Adblock breaks this site