[ C++ ] 計算時間
// C++的寫法,in millisecond,可計算到零點多秒
#include "stdio.h"
#include "time.h"
#include "stdlib.h"
int main(int argc, char *argv[]){
clock_t start_time, end_time;
float total_time = 0;
start_time = clock(); /* mircosecond */
//do something here
end_time = clock();
/* CLOCKS_PER_SEC is defined at time.h */
total_time = (float)(end_time - start_time)/CLOCKS_PER_SEC;
printf("Time : %f sec \n", total_time);
}
-http://test.cappsule.co/2010/06/c.html
留言
張貼留言