Xperf times vs KeQueryPerformanceCounter RRS feed

  • Question

  • 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.
    Monday, May 4, 2009 3:25 PM

All replies

  • Hi Frank,

    For on/off performance analysis, including resume scenario please refer to

    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?

    Tuesday, May 12, 2009 5:45 AM