Hi,

I'm buying a laptop and open to using any operating system. Macs being Unix based makes them very appealing to me and I'm trying to convince myself Mac is the way to go. I am used to reading specs for Pentium based machines and don't know how to compare to the processor speeds for Macs. Is a G4 933 MHz going to perform like a Pentium IV 2.4 GHz machine? (They cost about the same.)

To solve this problem I have written a bit of C code (and stolen pieces from the internet too) that I'd like to use as a benchmark for testing various Mac and Wintel machines. I want to be able to walk into a Mac store, pop in a CD and run the benchmark software. Like taking a car for a test drive. My problem is I cannot complile the software for Mac. If someone could compile it on Mac using gcc and email me the Mac executable, gcc version number, and command used to compile (optimizers, etc.) I'd be very grateful. Of course I'll post results once I've done the tests.

I've attached the code below optimistically hoping someone will help me.

Thanks,

Peter

Code:#include <stdlib.h> #include <stdio.h> #include <math.h> #include <time.h> #define size 50000000 #define size2 5000000 /*should be greater than number of primes < 2*size+3 */ struct vector { double *p; long l; /*length (a.k.a. number of elements)*/ }; void integral(void){ /*based on code from http://www.math.purdue.edu/~dvb/timing.html*/ double sum = 0, delta = 0.025, x = -5; double y, z; int i, j,k; clock_t start; start=clock(); for(i=0; i <400; i++) {x += delta; y = -5; for(j=0; j<400; j++) {y += delta; z=-5; for(k=0;k<400;k++) {z += delta; if(x*x+y*y+z*z<25) sum += exp(-x*x)*cos(y*y)*cos(z*z);}}} sum=sum*delta*delta*delta; /*printf("integral=%f10\n", sum);*/ printf("execution time for integral = %g seconds\n",((double)(clock()-start))/CLOCKS_PER_SEC); } void prime (void){ /*based on code from http://www.math.purdue.edu/~dvb/timing.html*/ int i, p, count=1; int x, xisprime, sqrtx; clock_t start; start=clock(); p = 3; for(x=3; count < 300000; x+=2) { xisprime = 1; sqrtx = (int) sqrt(x); for(i=3; i<= sqrtx; i++) if(x%i == 0) {xisprime = 0; break;}; if(xisprime) {count++; p=x;}; } /*printf("the %ith prime is %i\n", count, p);*/ printf("execution time for prime = %g seconds\n",((double)(clock()-start))/CLOCKS_PER_SEC); } void goldbach(void){ /*based on code from http://www.math.purdue.edu/~dvb/timing.html*/ int i,j, diff,inc,count=0; int limit, top,maxp = 3, maxq=3; char *isprime; /* treated like an integer array */ int *primes; double x; int test; clock_t start; start=clock(); isprime = (char *)malloc((size_t)(size*sizeof(char))); limit = (int) sqrt(2*size + 3.5) ; primes = (int *)malloc((size_t)(size2*sizeof(int))); if((isprime==NULL)|| (primes == NULL)) {printf("Out of memory\n"); exit(0);} for(i=0;i<size;i++) isprime[i]=1; for(i=0;i<limit; i++) {inc = 2*i+3; for(j=3*(i+1); j<size; j+=inc) isprime[j]=0;} for(i=0;(i<size)&&(count<size2);i++) if(isprime[i]){ primes[count] = 2*i+3; count++;} top= 2*size; for(i=6; i <= top ; i+=2) {test = 0; for(j=0; primes[j]<i;j++) {diff = i - primes[j]; if(isprime[(diff-3)/2]) {/*printf("%i = %i + %i\n", i, primes[j], diff);*/ test = 1; if(primes[j]>=maxp) {maxp = primes[j]; maxq=diff;} break;}} if(test == 0) {printf("Goldbach fails for %i\n", i); exit(0); }} /*printf("Goldbach true up to %i\n max partition: %i+%i\n", top, maxp, maxq);*/ printf("execution time for Goldbach = %g seconds\n",((double)(clock()-start))/CLOCKS_PER_SEC); } void dynamicfnc(void){ struct vector vec; long requestedlength=3000; register long i,j; clock_t start; start=clock(); for(j=0;j<1000000;j++){ vec.p=(double*)calloc(requestedlength, sizeof(double)); if (vec.p==NULL) { printf("vec.p==NULL in vec.c/allocvec"); abort(); } vec.l=requestedlength; free(vec.p); vec.l=0; } printf("execution time for dynamicfnc = %g seconds\n",((double)(clock()-start))/CLOCKS_PER_SEC ); } int main(void) { clock_t start; start=clock(); integral(); prime(); goldbach(); dynamicfnc(); printf("total execution time = %g seconds\n",((double)(clock()-start))/CLOCKS_PER_SEC ); system("PAUSE"); return 0; }