#include <stdio.h> #include <time.h> // WARNING!! Pentium only! int RDTSC(void); #pragma aux RDTSC = ".586" "rdtsc" "shr eax, 8" "shl edx, 24" "or eax, edx" modify [eax edx] value [eax]; volatile time_t t; main(int argc, char * argv[]) { unsigned int cyclemark1; unsigned int cyclemark2; unsigned int dt; if(argc>1) sscanf(argv[1],"%d",&dt); else dt = 5; printf( "Please wait, this program takes about %d seconds to run.\n",dt+1 ); t = time(NULL); while( t==time(NULL) ); t = time(NULL); cyclemark1 = RDTSC(); while( dt+t>time(NULL) ); cyclemark2 = RDTSC(); printf( "Your Pentium compatible's clock rate is %g Mhz\n", ((double)(cyclemark2 - cyclemark1))/((double)1000000.0/256.0)/((double)dt)); } |