3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
純C/C++ clock()函數 資料來源: http://www.cplusplus.com/reference/ctime/clock/ http://puremonkey2010.blogspot.com/2010/08/c-cc.html 線上編譯器: https://www.tutorialspoint.com/compile_c_online.php code(計算時間差): #include "stdio.h" #include "stdlib.h" #include "time.h" int main( void ) { long i = 10000000L; clock_t start, finish; //typedef long clock_t; double duration; /* 測量一個事件持續的時間*/ printf( "Time to do %ld empty loops is \n", i ); start = clock(); while( i-- ) ; finish = clock(); duration = (double)(finish - start) / CLOCKS_PER_SEC; printf( "%f seconds\n", duration ); printf ("It took me %d clicks (%f seconds).\n",(finish - start),(double)(finish - start)/CLOCKS_PER_SEC); return 0; }

本文由jashliaoeuwordpress提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦