/* Adjust BUFLEN to match the cache size of your CPU. Program to check for scheduling problems on SMP systems. If there's a speedup on UP the kernel moving the process across CPU's is causing a significant number of cache reloads */ #include #include #define NITER 100000 #define BUFLEN (128*1024) /* 128k (size of Celeron Cache) */ int p[BUFLEN/sizeof(int)]; /*Hopefully gcc aligns this for us */ void main() { time_t t,t1; int i; while(1) { time(&t); for(i = 0; i < NITER; i++) memset(p,i++,BUFLEN); time(&t1); t1 -= t; printf("%d seconds for %d iterations\n",t1,NITER); } }