程序执行时间测试方法

2020-02-18  本文已影响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;
上一篇 下一篇

猜你喜欢

热点阅读