[fpc-pascal] Hmm 64 bit instructions for visual studio 2008 slower than doubles too ?

Skybuck Flying skybuck2000 at hotmail.com
Mon Mar 10 21:02:08 CET 2008


Hmmm.

Visual Studio 2008 seems to produce even slower code for the True 64 bit 
integers.

Also when I set it to release, something strange happens and it only take 7 
ticks or so... while normally it takes 5 million ticks ?

Weird.

// Test64BitPerformance.cpp : Defines the entry point for the console 
application.
//
#include "stdafx.h"
#include "windows.h"

long long TestSimulatedInt64Performance()
{
int vIndex;
long long a;
long long b;
long long c;
a = 0;
b = 1;
c = 2;
for (vIndex = 0; vIndex < 10 * 1024 * 1024; vIndex++)
{
// 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 / 5;
b = b / 5;
c = c / 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;
}
return a + b + c;
}
double TestDoublePerformance()
{
int vIndex;
double a;
double b;
double c;
a = 0;
b = 1;
c = 2;
for (vIndex = 0; vIndex < 10 * 1024 * 1024; vIndex++)
{
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;
}
return a + b + c;
}


int _tmain(int argc, _TCHAR* argv[])
{
LARGE_INTEGER Tick1;
LARGE_INTEGER Tick2;
int vLoop;
for (vLoop=1; vLoop <= 10; vLoop++)
{
Sleep( 1000 );
QueryPerformanceCounter( &Tick1 );
TestSimulatedInt64Performance();
QueryPerformanceCounter( &Tick2 );
printf( "Simulated Int64 Ticks: %lld \n", Tick2.QuadPart-Tick1.QuadPart );
Sleep( 1000 );
QueryPerformanceCounter( &Tick1 );
TestDoublePerformance();
QueryPerformanceCounter( &Tick2 );
printf( "Double Ticks: %lld \n", Tick2.QuadPart-Tick1.QuadPart );
}
getchar();

return 0;
}

Bye,
  Skybuck. 




More information about the fpc-pascal mailing list