/* speed.c - speedtest */ #include #include #include #include #include #include #define N 10E6 long long cycles_last = 0; long long cycles_total = 0; long long cycles_average = 0; __inline__ unsigned long long cycles() { unsigned long long int result=0; unsigned long int upper, lower,tmp; __asm__ volatile( "0: \n" "\tmftbu %0 \n" "\tmftb %1 \n" "\tmftbu %2 \n" "\tcmpw %2,%0 \n" "\tbne 0b \n" : "=r"(upper),"=r"(lower),"=r"(tmp) ); result = upper; result = result<<32; result = result|lower; return(result); } 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