Xperf时间与KeQueryPerformanceCounter相比 [英] Xperf times vs KeQueryPerformanceCounter

查看:141
本文介绍了Xperf时间与KeQueryPerformanceCounter相比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在恢复周期中分析内核模式驱动程序。我运行Xperf为:xperf -on ResumeTrace -stackwalk Profile。我还在我的驱动程序中添加了代码,用于测量函数所需的时间,使用KeQueryPerformanceCounter。我遇到的问题是时间不匹配:
- Xperf表示fcn A具有更大的"重量"。比fcn B大约10%;
- KeQueryPerformanceCounter表示fcn B比fcn A花费大约15倍的运行时间。再次,似乎"重量"也是如此。在Xperf中是msec,它与KeQueryPerformanceCounter的不匹配。

我也使用PwrTest来测量恢复时间,这些更接近KeQueryPerformanceCounter。所以我不确定Xperf是否正在给我正确的数据或者我不明白Xperf究竟测量的是什么/如何。

感谢您的任何建议。

解决方案

您好Frank,

对于开/关性能分析,包括恢复方案,请参阅 http://www.microsoft.com/whdc/system/sysperf/On-Off_Transition.mspx

XPerf依靠ETW进行跟踪捕获,默认情况下使用QPC(与您自己的测量代码相同)。 QPC的精度约为1us。在某些地方,xperf将其舍入为ms,但基本精度仍为微秒。

10%与1500%的偏差毫无意义。 XPerf分析非常精确,并且已在多个平台上经过多年的验证。所以我要问你是如何用KeQueryPerformanceCounter测量函数A和B的?您如何记录您测量的数据?您是否确保不包括测量记录的成本?您需要手动测量这些数据点而不是在函数A和B的序言/结尾中记录ETW事件的任何原因吗?

感谢,
迈克尔

I'm attempting to profile a kernel mode driver during a resume cycle.  I run Xperf as : xperf -on ResumeTrace -stackwalk Profile.  I've also added code in my driver to measure the time a function takes, using KeQueryPerformanceCounter.  The issue I have is the times do not match:
- Xperf indicates fcn A has a larger "weight" than fcn B by ~10%;
- KeQueryPerformanceCounter indicates fcn B takes ~15 times more time to run than fcn A.

Also, it seems that the "weight" in Xperf is msec, which does not match that of KeQueryPerformanceCounter.

I've also used PwrTest to measure resume times, and these are closer to KeQueryPerformanceCounter.  So I am not sure if Xperf is giving me the correct data OR I don't understand exactly what/how Xperf is measuring.

Thanks for any advice.

解决方案

Hi Frank,

For on/off performance analysis, including resume scenario please refer to http://www.microsoft.com/whdc/system/sysperf/On-Off_Transition.mspx.

XPerf relies on ETW for trace capture, and by default uses QPC (same as your own measuring code). Precision of QPC is about ~1us. In some places, xperf rounds it to ms, but underlying precision is still in microseconds.

The deviation of 10% vs 1500% makes no sense. XPerf profiling is very precise and has been verified over a course of numerous years across a wide range of platforms. So I have to ask how are you measuring functions A and B with KeQueryPerformanceCounter? How are you logging the data you measure? Do you make sure not to include the cost of logging in your measurement? Any reason you need to manually measure these data points rather than logging ETW events in prologue/epilogue of functions A and B?

Thanks,
Michael


这篇关于Xperf时间与KeQueryPerformanceCounter相比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆