简体   繁体   English

测量轮廓函数的时间

[英]measuring time of a profiled function


I'm trying to profile a function in another method, so in order to measure its time, I'm doing something like this: 我正在尝试使用另一种方法来分析一个函数,因此,为了测量其时间,我正在执行以下操作:

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

... Do profiling stuff ... 

ResumeOtherProcessThreads();
m_lastTime = GetCurrentTime();  

... Let profiled process run ....

This is what I do each sample and I consider the time in which I sampled to be "runningTime". 这是我每次采样所要做的,并且我将采样时间视为“ runningTime”。 But for some reason I get that "runningTime" is much smaller than the actual running time. 但是由于某种原因,我发现“ runningTime”比实际的运行时间小得多。
This code runs tens of thousands times a second. 这段代码每秒运行数万次。

does anybody know what's wrong with it? 有人知道这是怎么回事吗?
does it have something to do with the Suspend/ Resume things? 它与挂起/恢复事情有关吗?
thanks :) 谢谢 :)

If your process is blocked by another process, your timing will be wrong. 如果您的进程被另一个进程阻塞,那么您的时间安排将是错误的。

Why are you not using a tool (like cachegrind to profile? 为什么不使用工具(例如cachegrind进行分析?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM