开发者

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". But for some reason I get that "runningTime" is much smaller than the actual running time.

This code runs tens of tho开发者_如何学Pythonusands 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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜