本文介绍了测量轮廓函数的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我试图用另一种方法分析一个函数,所以为了测量它的时间,我正在做这样的事情:


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 ....

这就是我做的每个样本,我认为我采样的时间是runningTime".但出于某种原因,我认为runningTime"比实际运行时间小得多.
此代码每秒运行数万次.

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 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.

您为什么不使用工具(如cachegrind)来分析?

Why are you not using a tool (like cachegrind to profile?

这篇关于测量轮廓函数的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 06:31