Linked by Christopher W. Cowell-Shah on Thu 8th Jan 2004 19:33 UTC
General Development This article discusses a small-scale benchmark test run on nine modern computer languages or variants: Java 1.3.1, Java 1.4.2, C compiled with gcc 3.3.1, Python 2.3.2, Python compiled with Psyco 1.1.1, and the four languages supported by Microsoft's Visual Studio .NET 2003 development environment: Visual Basic, Visual C#, Visual C++, and Visual J#. The benchmark tests arithmetic and trigonometric functions using a variety of data types, and also tests simple file I/O. All tests took place on a Pentium 4-based computer running Windows XP. Update: Delphi version of the benchmark here.
Permalink for comment
To read all comments associated with this story, please click here.
delphi benchmark
by Marc collin on Fri 9th Jan 2004 23:09 UTC

hi

i convert the code to delphi:

Code :


program Benchmark;

{$APPTYPE CONSOLE}

uses
SysUtils,
MMSystem,
Math;

var
startTime :Longint;
stopTime :Longint;
elapsedTime :Longint;

intMax :integer;
doubleMin ;) ouble;
doubleMax ;) ouble;
longMin :Int64;
longMax :Int64;
trigMax ;) ouble;
ioMax :integer;

intArithmeticTime: double;
doubleArithmeticTime ;) ouble;
longCountTime ;) ouble;
trigTime ;) ouble;
ioTime ;) ouble;
totalTime ;) ouble;


function intArithmetic(intMax:integer):Longint;
var
intResult :integer;
i :integer;
begin

startTime := timeGetTime;
intResult := 1;
i := 1;

while (i < intMax) do
begin
intResult := intResult - i;
inc(i);
intResult := intResult + i;
inc(i);
intResult := intResult * i;
inc(i);
intResult := intResult div i;
inc(i);
end;

stopTime := timeGetTime;
elapsedTime := stopTime - startTime;

WriteLn('Int arithmetic elapsed time: ' + inttostr(elapsedTime) + 'ms with max of ' + inttostr(intMax));
WriteLn(' i: ' + inttostr(i) + ' intResult: ' + inttostr(intResult));
result := elapsedTime;

end;

function doubleArithmetic(doubleMin, doubleMax:Double):Longint;
var
doubleResult ;) ouble;
i :double;
begin

startTime := timeGetTime;

doubleResult := doubleMin;
i := doubleMin;

while (i < doubleMax) do
begin
doubleResult := doubleResult - i;
i:=i+1;
doubleResult := doubleResult + i;
i:=i+1;
doubleResult := doubleResult * i;
i:=i+1;
doubleResult := doubleResult / i;
i:=i+1;
end;

stopTime := timeGetTime;
elapsedTime := stopTime - startTime;

WriteLn('Double arithmetic elapsed time: ' + inttostr(elapsedTime) + ' ms with min of ' + floattostr(doubleMin) + ', max of ' + floattostr(doubleMax));
WriteLn(' i: ' + floattostr(i) + ' doubleResult: ' + floattostr(doubleResult));
result := elapsedTime;


end;

function longArithmetic(longMin, longMax:Int64):Longint;
var
longResult :Int64;
i :Int64;
begin

startTime := timeGetTime;

longResult := longMin;
i := longMin;

while (i < longMax) do
begin
longResult := longResult - i;
inc(i);
longResult := longResult + i;
inc(i);
longResult := longResult * i;
inc(i);
longResult := longResult div i;
inc(i);
end;

stopTime := timeGetTime;
elapsedTime := stopTime - startTime;

WriteLn('Long arithmetic elapsed time: ' + inttostr(elapsedTime) + ' ms with min of ' + inttostr(longMin) + ', max of ' + inttostr(longMax));
WriteLn(' i: ' + inttostr(i));
WriteLn(' longResult: ' + inttostr(longResult));
result := elapsedTime;


end;

function trig(trigMax:double):Longint;
var
sine :double;
cosine :double;
tangent :double;
logarithm :double;
squareRoot :double;
i :double;
begin


startTime := timeGetTime;

sine := 0.0;
cosine := 0.0;
tangent := 0.0;
logarithm := 0.0;
squareRoot := 0.0;
i := 0.1;
while (i < trigMax) do
begin
sine := Sin(i);
cosine := Cos(i);
tangent := Tan(i);
logarithm := Log10(i);
squareRoot := sqrt(i);
i := i+1;
end;

stopTime := timeGetTime;
elapsedTime := stopTime - startTime;

WriteLn('Trig elapsed time: ' + inttostr(elapsedTime) + ' ms with max of ' + floattostr(trigMax));
WriteLn(' i: ' + floattostr(i));
WriteLn(' sine: ' + floattostr(sine));
WriteLn(' cosine: ' + floattostr(cosine));
WriteLn(' tangent: ' + floattostr(tangent));
WriteLn(' logarithm: ' + floattostr(logarithm));
WriteLn(' squareRoot: ' + floattostr(squareRoot));
result := elapsedTime;


end;

function io(ioMax:integer):Longint;
var
textLine :string;
i:integer;
myLine:string;
F:TextFile;
begin

startTime := timeGetTime;;

textLine := 'abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567 890abcdefgh';
i := 0;
myLine := '';

assignfile(F,'TestDelphi.txt');
rewrite(F);
while (i < ioMax) do
begin
Writeln(F,textLine);
inc(i);
end;

CloseFile(F);

stopTime := timeGetTime;
elapsedTime := stopTime - startTime;

WriteLn('IO elapsed time: ' + inttostr(elapsedTime) + ' ms with max of ' + inttostr(ioMax));
WriteLn(' i: ' + inttostr(i));
WriteLn(' myLine: ' + myLine);
result := elapsedTime;
end;

begin
intMax := 1000000000;
doubleMin := 10000000000;
doubleMax := 11000000000;
longMin := 10000000000;
longMax := 11000000000;
trigMax := 10000000;
ioMax := 1000000;


WriteLn('Start Delphi benchmark');

intArithmeticTime := intArithmetic(intMax);
doubleArithmeticTime := doubleArithmetic(doubleMin, doubleMax);
longCountTime := longArithmetic(longMin, longMax);
trigTime := trig(trigMax);
ioTime := io(ioMax);
totalTime := intArithmeticTime + doubleArithmeticTime + longCountTime + trigTime + ioTime;

WriteLn('Total Delphi benchmark time: ' + floattostr(totalTime) + ' ms');
WriteLn('End Delphi benchmark');

Readln;

end.