滑蒻稽的博客

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\n",(dur/CLOCKS_PER_SEC));
}

精确到毫秒

posted @ 2021-02-01 20:40  huaruoji  阅读(113)  评论(0编辑  收藏  举报