Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 测量轮廓函数的时间_C++_Profiling_Timing - Fatal编程技术网

C++ 测量轮廓函数的时间

C++ 测量轮廓函数的时间,c++,profiling,timing,C++,Profiling,Timing,我试图用另一种方法分析函数,因此为了测量其时间,我做了如下操作: double diffTime = GetCurrentTime() - m_lastTime; SuspendOtherProcessThreads(); double runningTime += diffTime; ... Do profiling stuff ... ResumeOtherProcessThreads(); m_lastTime = GetCurrentTime(); ... Let profi


我试图用另一种方法分析函数,因此为了测量其时间,我做了如下操作:

double diffTime = GetCurrentTime() - m_lastTime;
SuspendOtherProcessThreads();
double runningTime += diffTime;

... Do profiling stuff ... 

ResumeOtherProcessThreads();
m_lastTime = GetCurrentTime();  

... Let profiled process run ....
这就是我所做的每一个样本,我考虑了我被取样为“运行时间”的时间。 但由于某些原因,我发现“运行时间”比实际运行时间小得多。
这段代码每秒运行数万次

有人知道它出了什么问题吗?
它是否与挂起/恢复操作有关?

谢谢:)

如果您的进程被另一个进程阻止,则您的计时将错误


你为什么不使用工具(比如分析?

没有明显的错误,但是你没有给我们足够的信息继续下去。如果
diffTime
太小,可能是舍入错误,或者分析的内容比你想象的要花更多的时间,或者可能是你在测量“实际运行时间”错了,没有办法说。评测有多种含义。你是只想衡量它所花费的时间,还是想找出哪些代码点可以有效地进行优化?这是不同的任务。Beta-我不是在衡量评测时间,而是“非评测”如果你真正关心的是找到你可以优化的代码点,让代码运行得更快,这可能看起来很奇怪,但这与测量是非常不同的。