C++程序计时器模版(用于计算某个代码块用时)

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

int main()
{
    double dur;
    clock_t start,end;
    start = clock();
    foo();//dosomething
    end = clock();
    dur = (double)(end - start);
    printf("Use Time:%f
",(dur/CLOCKS_PER_SEC));
}

精确到毫秒

原文地址:https://www.cnblogs.com/huaruoji/p/14425572.html