/* * use 'gcc -O3 -DGETPID getid.c -o testgetpid' to make getpid system call * use 'gcc -O3 getid.c -o testmyid' to call the getid() routine * * use 'time testgetpid' to get the total time when making 10M getpid calls * use 'time testmyid' to get the total time when calling 10M getid routines */ #include #include #include int myid = 1001; int getid() { return myid; } int a[1000]; main() { int i, j; for (i=0; i<100000000; i++) { #ifndef GETPID a[i%1000] = getid(); #else a[i%1000] = getpid(); #endif } printf("a[999] = %d\n", a[999]); }