/* * gcc -O3 -march=i686 -fomit-frame-pointer rcutest.c -o rcutest-i386 * gcc -march=i386 rcutest.c -o rcutest-i686 */ /* ----------------------------------------- usage: % gcc -O3 rcutest.c -o rcutest % ./rcutest 1 # Number of threats ----------------------------------------- */ #include #include #include #include #include #include #include #include #define LOOP (5000000) void child_shmfile(){ int i,fd; char buf[100],fname[100]; sprintf(fname,"/tmp/file.%d",getpid()); fd = open(fname,O_RDWR|O_CREAT|O_TRUNC); if( fd < 0 ){ printf("NOTE: Process(%d) can not open %s",getpid(),fname); return; } for(i=0;i0 ){ cproc++; } } waitpid(-1,NULL,0); gettimeofday(&etm, NULL); sec = etm.tv_sec - stm.tv_sec; usec = etm.tv_usec - stm.tv_usec; if( usec<0 ){ sec--; usec = 1000000 + usec; } printf("[%d Proc x %d Loop] Time: %.4f \n",cproc,LOOP, (double)sec + ((double)usec)/10000000.0 ); }