- Joined
- Apr 22, 2005
- Sythe Gold
- 23
- Messages
- 7,825
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:
Here is the code I used for the Visual Basic 6 Benchmark:
And the Borland Delphi 6 equivalent:
Java source (thanks Cheese Police):
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.
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;
}
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
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.
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");
}
}
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.


















