summing large arrays - or - performance of tight loops
Manfred Nowak
svv1999 at hotmail.com
Thu Apr 19 12:01:42 PDT 2007
Dave wrote
> Mine were ran on a P4 chip and an AMD64 chip (original was
> Turion).
It is disgusting to see, that three random benchmarkers all get
different results. Mine were run on an AMD64 X2 under WinXP32 and
compiled with DMD1.012.
Quotients (foreach/other):
Thomas: 200%
Dave: 100%
me: 85%
What causes those huge differences?
Here is my main:
import std.stdio, std.perf;
void main(){
const int f= 256;
int[ ] a= new int[ 1024*1024*f];
auto c=new PerformanceCounter;
auto c2=new PerformanceCounter;
c.start;
for(int i= 1; i<=5120/f; i++)
volatile sum_foreach( a);
c.stop;
volatile auto t= c.microseconds;
c2.start;
for(int i= 1; i<=5120/f; i++)
volatile sum_array( a);
c2.stop;
writefln( "%s %s %s"
, cast(real)t/c2.microseconds
, t
, c2.microseconds
);
}
-manfred
More information about the Digitalmars-d
mailing list