2009-07-30 31 views

回答

1

clock() function

#include <time.h> 

clock_t start = clock(); 
//... 
//do something 
double total = (double) (clock() - start)/CLOCKS_PER_SEC; 

這裏總變量保存的時間(以秒爲單位)做一些部分需要完成。

請注意,如果您需要更準確的計時,則可以使用QueryPerformanceCounterQueryPerformanceFrequency函數,但它們特定於Windows平臺。

1

如果您試圖計算交換機執行多長時間,請嘗試在之前和之後調用gettickcount,然後再減去這兩個值,這會延遲毫秒。