所以這是非常基本的,但我真的不知道C.獲取的時間量在C運行功能
我想找到的東西需要運行,沒有時鐘(CPU)週期的毫秒數。
我嘗試使用
struct timeval start,end;
double dif;
gettimeofday(&start, 0);
//do stuff
gettimeofday(&end, 0);
dif = (end - start)/1000.0;
printf("The time taken was %lf \n",dif);
我收到的時候我嘗試編譯此錯誤:
bubble.c: In function ‘main’:
bubble.c:55: error: invalid operands to binary - (have ‘struct timeval’ and ‘struct timeval’)
完美,謝謝! – switz
在大多數情況下,這應該可以正常工作。但我建議使用帶有「struct time_val」的timersub()來代替。 – paulsm4
@moshbear - 你改變了我的帖子:)你目前的版本* *更*脆弱:) – paulsm4