C語言紀錄程式執行時間的方法
最近一直在比程式的執行速度,測的方法又五花八門@@
這邊就記一個用time.h中的函式來計算所花時間的辦法:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() {
 
    clock_t start, end;
   
    // Start Record the time
    start = clock();
   
// Your program....

    // Record the end time
    end = clock();

    double diff = end - start; // ms
    printf(" %f  ms" , diff);
    printf(" %f  sec", diff / CLOCKS_PER_SEC );

    return 0;
}
arrow
arrow
    文章標籤
    執行時間 C
    全站熱搜

    JL8051 發表在 痞客邦 留言(0) 人氣()