Benchmarks

To compare the speed of all Linux computers I get my fingers on, I use a simple program to calculate n! (n<120000). The program was compiled with gcc, optimization enabled (-O2). Here are the results:

25000! 50000! 100000!
i386 33 MHz 421 s 1847 s 8321 s
SPARC 2 358 s
i486 33 MHz 276 s 1201 s 5317 s
SPARC 10 146 s 633 s 2738 s
i486DX2 66 MHz 143 s 625 s 2730 s
SPARC 20 116 s 508 s 2210 s
PENTIUM 60 MHz 70 s 302 s 1357 s
ULTRA SPARC 167MHz 46 s 206 s 897 s
PENTIUM 100 MHz 43 s 186 s 819 s
PENTIUM 133 MHz 32 s 141 s 630 s
K6-2 333 MHZ 9 s 38 s
Duron 1000 MHz 2 s 13 s
XP@166*9 2 s 5 s 26 s
A64-3000+, SLAMD64 1 s 4 s 15 s
A64-X2 3800, sflack 1 s 3 s 14 s
core i5-2400 0 s 2 s 6 s
Pentium G3420 300ms 1020ms 4240ms
Pentium G4500 230ms 900ms 3976ms
Atom CPU Z3736F 1200ms 4850ms 19350ms
Atom Z530 2200ms 9500ms 42000ms
POWER5 1.65GHz -O3 1s 5s 21s
Dreambox 250MHz -O3 19s 86s 374s
N800 330MHz -O3 17s 83s 352s
RPi 800MHz -O3 7s 37s 183s
RK3066 ??1.3GHz -O3 2s 12s 54s
RK3188 1.6GHz -O2=03 2s 9s 40s
ingenic Xburst 1.2GHz -O3 4s 19s 84s
Xburst -O3 -mips32r2 3800ms 17200ms 75400ms
RPi 2 900MHz -O2=O3 4400ms 16400ms 66400ms
Orange Pi PC 1.2GHz -O3 2100ms 8900ms 40000ms
/*********************************************************************/
unsigned int f[200000];
#include <stdio.h>
#include <sys/time.h>

int compute(n,f) unsigned int n, *f;
{unsigned int i=1,j,k,l,m=1; f[1]=1; 
 for (j=2; j<=n; j++) 
   {l=0; for (k=m; k<=i; k++) 
      {l=j*f[k]+l; f[k]=l&0x7FFF; l=l>>15;} 
    if (l) {f[++i]=l&0x7FFF; 
        if (l>>15) f[++i]=l>>15;} 
    if (!f[m]) m++;} 
 *f=i;}

int print_result(n,f) unsigned int n, *f;
{unsigned int i=*f,j,k,l=0,m=(i-1)%4+15; 
 while(i) {j=0; for (k=0;k<4;k++) {j=(j<<1)+((f[i]>>m)&1);if(!m--){m=14;i--;}} 
 if (!(l&0x3F)) putchar('\n'); putchar(j<10?j+'0':j-10+'A'); l++;} 
 printf("\n\n%d! has %d hex digits\n",n,l);}

int main()    /* int must be >= 4 byte */
{ unsigned int i, n; struct timeval t1,t2; 
 do {
   printf("calculate n! (n<=120000) n=? ");
   i=  scanf("%d",&n);
 } while (n>120000 );
 gettimeofday(&t1, 0); compute(n,f); gettimeofday(&t2, 0);
/*print_result(n,f);*/ 
printf("time = %d ms\n",(int)(t2.tv_sec*1000+t2.tv_usec/1000-t1.tv_sec*1000-t1.tv_usec/1000));} 

/*********************************************************************/
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License