c++ 程序执行时间
opencv的:
-
-
//created:2020.04.06 by Andison
-
-
#include<iostream>
-
#include<vector>
-
#include<algorithm>
-
#include <opencv2/opencv.hpp>
-
using namespace std;
-
//读取路径下的特定格式文件的路径,返回按文件名升序排列的文件路径vector
-
int getFilePaths(vector<string> &filepaths, cv::String filePath);
-
-
int main()
-
{
-
vector<string> filePaths;
-
cv::String folderPath = "C:\\Users\\sun\\Desktop\\paths\\*.txt";
-
double t1 = cv::getTickCount();
-
getFilePaths(filePaths, folderPath);
-
double t2 = cv::getTickCount();
-
cout << "Time elapsed: " << 1000 * (double)(t2 - t1) / cv::getTickFrequency() <<" ms."<< endl;
-
-
getchar();
-
return 0;
-
}
单位ms:
-
clock_t start_time = clock();
-
auto faces = FD.detect(simage);
-
clock_t finish_time = clock();
-
double total_time = (double)(finish_time - start_time) / CLOCKS_PER_SEC;
-
std::cout << "time" << total_time * 1000 << "ms" << std::endl;
使用时应该添加如下文件包含#include<windows.h> 。
程序执行时间:单位是ms,
DWORD start_time = GetTickCount();
printf("decode ok %d %u\n", avCodecCtx->flags, GetTickCount() - start_time);
start_time = GetTickCount();
C++ clock()计时函数
核心:clock_t s_time; (double)(e_time-s_time)/CLOCKS_PER_SEC
#include <iostream>
#include <time.h>
using namespace std;
int main(int argc, const char * argv[])
{
clock_t s_time, e_time;
s_time=clock();
for(int i=0; i<100000000; i++)
{
i-=1; i+=1;
}
e_time=clock();
cout<<"Total time:"<<(double)(e_time-s_time)/CLOCKS_PER_SEC<<"S";
return 0;
}
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/88957435
- 点赞
- 收藏
- 关注作者
评论(0)