分析C 程序
Profiling C++ program
我有一个函数可以在时间上配置。实际上,该功能显示在主函数中检查时13222668
微秒(13秒)的时间。然后我开始介绍功能的不同部分,最小示例如下:
#include <iostream>
#include <sstream>
#include <string>
#include <chrono>
using namespace std::chrono;
unsigned int match_time;
int func(){
unsigned int i = 0;
while(i < 20){
high_resolution_clock::time_point t1 = high_resolution_clock::now(); // if I start the time from here, it shows me just `827687` milliseconds (827 milliseconds).
//code....
{
//code...
{
//code....
}
//code....
}
high_resolution_clock::time_point t2 = high_resolution_clock::now();
auto duration = duration_cast<microseconds>( t2 - t1 ).count();
match_time += duration;
i++;
}
return 0;
}
如果我在段循环内启动时间,则仅显示827687
微秒(827毫秒),但是如果我在while wily loop
high_resolution_clock::time_point t1 = high_resolution_clock::now();
while(i < 20){
}
high_resolution_clock::time_point t2 = high_resolution_clock::now();
auto duration = duration_cast<microseconds>( t2 - t1 ).count();
match_time += duration;
我有一个高时间13222668
微秒(13秒),我对此表示怀疑。
同样,当我检查了不同的语句执行时间时,我会在打印时获得0
的时间(我认为这是打印问题),而求和match_time += duration;
在数百万次运行中显示了其中的时间(827毫秒)。
我想知道我的时间分析方式是否正确,以及为什么时间在时循环和外部循环(大约是外部循环时间我怀疑)。由于任何其他原因,我的代码是否悬挂了一段时间。
不能只是您的 match_time
不是初始化的吗?
相关文章:
- 消息分析程序继承的替代方法
- 使用完美记录进行分析Linux应用程序
- 使用 uftrace 分析C++程序后如何理解 2 个 main() 函数
- 分析C 程序
- 使用 Frama-C 分析一个简单的C++程序
- 谷歌性能工具可以用于分析C应用程序吗?
- 在我的程序中分析 CPU 使用情况的最佳选择
- 分析应用程序的挂起转储
- 如何在独立程序中使用 LLVM 分析传递
- 瓦尔格林德挂起来分析多线程程序
- 如何分析程序运行时间
- 在C++程序中实现软件测试的边界值分析
- 如何分析C/ c++应用程序中内存访问所花费的时间
- 有可能分析程序的返回值吗?
- 如何使用消息队列分析GUI应用程序
- 利用英特尔Vtune放大器XE2016对一个无法工作的VS2015控制台应用程序进行高级热点分析
- 如何在程序集级别分析c++函数
- Windows应用程序崩溃.dmp文件分析在visual studio
- BFD:矮人错误:在使用GNU 4.7.2使用HPCToolKit分析openmp程序时
- 编写程序分析文件