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;
网友评论