C++计时
-
使用C语言中的
(time.h)
https://blog.csdn.net/u011391905/article/details/53034200 -
OpenCV
https://github.com/XYZ-qiyh/PlaneFitting/blob/master/src/test.cpp#L23-L26
// 计时原理:t秒内的count数/一秒的count数=代码段运行所需的时间
double t = (double)getTickCount();
// do something ...
t = ((double)getTickCount() - t)/getTickFrequency(); // 单位: seconds
- OpenCV C++计时2
getTickCount()返回操作系统启动到当前所经过的计时周期
getTickFrequency()返回每秒的计时周期(即Tick Per Second)
int64_t start = cv::getTickCount();
// type your code here
int64_t end = cv::getTickCount();
double runtime = double(end - start) / double(cv::getTickFrequency()); // 计时单位: μs
getTickCount()函数在core.hpp中定义,返回值类型为int64,占用8个字节。
代码中我们使用了int64_t数据类型,之前出现过这样的情况:计时结果为负,将int改为int64_t后解决了此问题
-
Linux C/C++获取程序运行时间
https://blog.51cto.com/u_15786574/5715356 -
Chrono in C++
https://www.geeksforgeeks.org/chrono-in-c/

浙公网安备 33010602011771号