在CPU中花费的时间比实际情况更快
Time spends in CPU faster than in reality
我想知道为什么我的整个应用程序在小于8 seconds
的时间内运行,而从clock_gettime
获得的时间是19.3468 seconds
,这是实际情况的两倍多。问题出在哪里?
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time_start);
... // many calculations
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time_stop);
double time_diff=(time_stop.tv_sec-time_start.tv_sec+
(1e-9)*(time_stop.tv_nsec-time_start.tv_nsec);
更新:
我没有明确使用任何OpenMP。
CLOCK_MONOTONIC如果您想测量总运行时间,包括阻止等待IO所花费的时间,则应该使用,但它也将包括程序试图运行时其他进程被调度所导致的速度减慢。
相关文章:
- 在已经使用Git的情况下减少编译时间
- 将树节点添加到向量向量中的 n 元树遍历的平均和最坏情况时间复杂度是多少?
- 通常使用什么方法来检测时间情况?
- C++ - 最坏情况和平均情况插入时间复杂度在 std::unordered_map <int,int>?
- 使用 Qt 测量过程的实际运行时间
- 如何在给定时钟偏移的情况下正确获取时间
- 我需要线程函数在不停止实际程序的情况下,每2秒打印一次随机数
- 测量任何 Windows 可执行文件的内存使用情况和执行时间
- 编译器在这里做什么,允许在很少进行实际比较的情况下比较许多值
- 测量 std::系统的实际执行时间(以 C++ 为单位)
- 递归最糟糕的情况时间复杂性
- 在CPU中花费的时间比实际情况更快
- 为什么Crypto++认为我的消息比实际情况更大
- c++中函数参数的实际情况
- 在什么实际情况下bool(std::ifstream) != std::ifstream::good()
- visual当在C++中删除不完整的类型不是错误时,是否存在实际情况
- 编写程序需要实际的时间来执行c++
- 如何在运行时监控进程的资源使用情况(时间、内存)?
- 在 C 样式类型转换期间,关于强制转换对象的地址空间的实际情况
- 以复数表示的实际经过时间