I'm often surpised that the cheap commodity intel/amd cpus outperform the expensive enterprise RISC CPUs. Sure there are arguments about workload,cache,exacution pipelines,out of order execution and and holistic system balance (search usenet for my posts about this) but I would expect a $20,000.00 CPU to kick ass on a $2000.00 IN EVERY LOAD and it does not....
### THE TEST ###
cat <<> primes.c
#include
int
main(int argc, char *argv[])
{
int I1 = 1;
int I2 = 100000;
int I3;
int I4;
int I5;
int I6 = 0;
int I7;
printf("N primes up to ");
printf("%d", I2);
printf(" is: ");
REDO:
I3 = 2;
I4 = I1 / 2;
LOOP:
I5 = I1 % I3;
if (I5) {goto OK;}
goto NEXT;
OK:
I3++;
if (I3 <= I4) {goto LOOP;}
I6++;
I7 = I1;
NEXT:
I1++;
if (I1 <= I2) {goto REDO;}
printf("%d\n", I6);
printf("last is: %d\n", I7);
return 0;
}
EOF
gcc primes.c -o primes
time ./primes
N primes up to 100000 is: 9592
last is: 99991
real 0m X
user 0m Y
sys 0m Z
#### THE RESULTS #####
=============================
UltraSPARC-2i 450Mhz
real 0m46.27s
user 0m46.24s
sys 0m0.01s
============================
UltraSPARC-T1 1.2Ghz
real 0m32.13s
user 0m32.11s
sys 0m0.00s
============================
POWER3 450Mhz
real 0m22.40s
user 0m22.30s
sys 0m0.00s
============================
UltraSPARC-T2 1.2Ghz
time ./primes
N primes up to 100000 is: 9592
last is: 99991
real 0m16.81s
user 0m16.80s
sys 0m0.00s
sparcv9 processor operates at 1167 MHz
cc primes.c -o pri
time pri
N primes up to 100000 is: 9592
last is: 99991
real 0m17.62s
user 0m17.61s
sys 0m0.00s
============================
POWER5 1.65Ghz
real 0m11.60s
user 0m10.57s
sys 0m0.00s
============================
POWER5 1.9GHz
real 0m11.44s
user 0m8.71s
sys 0m0.00s
============================
UltraSPARC-IV+ 1.95Gz
real 0m8.86s
user 0m8.85s
sys 0m0.00s
============================
UltraSPARC-IV+ 2.1Ghz
real 0m8.22s
user 0m8.21s
sys 0m0.00s
==============================
POWER6 3.5GHz
real 0m7.97s
user 0m7.88s
sys 0m0.00s
=============================
Dual-Core AMD Opteron 2.8Ghz
real 0m3.729s
user 0m3.728s
sys 0m0.004s
=============================
Intel(R) P4 1.66GHz
real 0m2.879s
user 0m2.671s
sys 0m0.015s
==============================
Intel Pentium M 1.60GHz
real 0m2.710s
user 0m2.694s
sys 0m0.008s
==============================
Intel Quad 2.33Ghz
real 0m1.663s
user 0m1.662s
sys 0m0.002s
==============================
Intel(R) Core™2 Quad 2.4GHz
real 0m1.638s
user 0m1.625s
sys 0m0.010s
==============================
Intel Xeon(R) dual 3Ghz
real 0m1.325s
user 0m1.325s
sys 0m0.001s
==============================
Intel(R) Xeon(R) CPU E5450 @ 3.00GHz
real 0m0.82s
user 0m0.80s
sys 0m0.00s
No comments:
Post a Comment