rendered paste body/* speed.c - speedtest */#include <stdlib.h>#include <stdio.h>#include <sys/time.h>#include <time.h>#include <string.h>#include <unistd.h>#define N 10E6long 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<N; i++) { start_cycles = cycles(); cycles_last = cycles() - start_cycles; cycles_total += cycles_last; } cycles_average = cycles_total / N; after_clocks = cycles(); gettimeofday(&tv_after, NULL); t_before_ms = 1000*tv_before.tv_sec + tv_before.tv_usec/1000; t_after_ms = 1000*tv_after.tv_sec + tv_after.tv_usec/1000; t_ms = t_after_ms - t_before_ms; mips_cpu = (after_clocks - before_clocks)/(1E3*t_ms); printf("CPUs:\t\t %5.2f MIPS\n", mips_cpu); printf("Used time:\t %d ms\n", t_ms); printf("Cycles_last:\t %lld\nCycles_avg:\t %lld\n", cycles_last, cycles_average); return 0;}