/* speed.c - speedtest */ #include #include #include #include #include #include #define N 10E6 /* number of cycles we are using per call */ long long cycles_last = 0; long long cycles_worst = 0; long long cycles_total = 0; long long cycles_average = 0; __inline__ unsigned long long cycles() { unsigned long long x; __asm__ volatile ("rdtsc\n\t" : "=A" (x)); return x; } int main(int argc, char **argv) { int i,j; struct timeval tv_before; struct timeval tv_after; unsigned long long t_before_ms, t_after_ms; unsigned long long before_clocks, after_clocks; int t_ms; unsigned long long start_cycles; float mips_cpu, mips_per_ec; gettimeofday(&tv_before, NULL); before_clocks = cycles(); for(i=0; i