[fpc-pascal] Int64: Cross Compiler 2.1.4 Beta for X64 does not produce faster executables ?
Skybuck Flying
skybuck2000 at hotmail.com
Mon Mar 10 20:32:28 CET 2008
Hello,
The project/benchmark below was compiled with Delphi 2007 (produces 32 bit
instructions), and Free Pascal Cross Compiler 2.1.4 Beta for X64 (produces
64 bit instructions ???).
I see no major performance differences ?
I was expecting much better performance from the cross compiler but it's not
happening ?
Why is it not happening ?
Doesn't it use true 64 bit instructions ?
(How can I look at the produced assembler instructions ?)
Or is there another reason for it ?
// *** Begin of Benchmark ***
program Project1;
{$APPTYPE CONSOLE}
{
Test simulated large integer (int64) vs native floating point (double)
performance
version 0.01 created on 7 february 2008 by Skybuck Flying
My (Skybuck)'s Conclusions are:
1. Simulated ints faster for additions and subtractions than doubles.
2. Simulated ints slower for multiplications and divisions than doubles.
}
uses
SysUtils,
Windows;
function TestSimulatedInt64Performance : int64;
var
vIndex : integer;
a : int64;
b : int64;
c : int64;
begin
a := 0;
b := 1;
c := 2;
for vIndex := 0 to 10 * 1024 * 1024 do
begin
// additions faster with simulated int than doubles
a := a + 1;
b := b + 1;
c := c + 1;
// multiplications slower with simulated int than doubles
a := a * 5;
b := b * 5;
c := c * 5;
// divisions slower with simulated int than doubles
a := a div 5;
b := b div 5;
c := c div 5;
a := a + b;
b := b + c;
c := c + a;
// subtractions probably faster just like additions (not really tested :))
a := a - a;
b := b - b;
c := c - c;
end;
result := a + b + c;
end;
function TestDoublePerformance : double;
var
vIndex : integer;
a : double;
b : double;
c : double;
begin
a := 0;
b := 1;
c := 2;
for vIndex := 0 to 10 * 1024 * 1024 do
begin
a := a + 1;
b := b + 1;
c := c + 1;
a := a * 5;
b := b * 5;
c := c * 5;
a := a / 5;
b := b / 5;
c := c / 5;
a := a + b;
b := b + c;
c := c + a;
a := a - a;
b := b - b;
c := c - c;
end;
result := a + b + c;
end;
var
Tick1 : int64;
Tick2 : int64;
vLoop : integer;
begin
for vLoop := 1 to 10 do
begin
sleep( 1000 );
QueryPerformanceCounter( Tick1 );
TestSimulatedInt64Performance;
QueryPerformanceCounter( Tick2 );
writeln( 'Simulated Int64 Ticks: ', Tick2-Tick1 );
sleep( 1000 );
QueryPerformanceCounter( Tick1 );
TestDoublePerformance;
QueryPerformanceCounter( Tick2 );
writeln( 'Simulated Double Ticks: ', Tick2-Tick1 );
end;
readln;
end.
// *** End of Benchmark ***
Bye,
Skybuck.
More information about the fpc-pascal
mailing list