美文网首页
程序执行时间测试方法

程序执行时间测试方法

作者: 卡拉肖克_潘 | 来源:发表于2020-02-18 17:30 被阅读0次

    1、OpenCV c++版
    单位ms,但小数点精确度更高.

    #include “opencv2/opencv.h”
    double t = (double)getTickCount();
    
    //do what you want
    
    t = (double)getTickCount() - t;
    t=t*1000./cv::getTickFrequency();
    

    2、windows方法

    #include "time.h"
    #include <Windows.h>
    time_t Tstart = GetCurrentTime();
    
    //do what you want
    
    Tstart = GetCurrentTime() - Tstart ;
    

    3、c++

    #include<ctime>
    clock_t startTime,endTime;
    startTime = clock();//计时开始
    //do what you want
    endTime = clock();//计时结束
    cout << "The run time is: " <<(double)(endTime - startTime) / CLOCKS_PER_SEC << "s" << endl;
    

    相关文章

      网友评论

          本文标题:程序执行时间测试方法

          本文链接:https://www.haomeiwen.com/subject/gzntxhtx.html