<div class="gmail_quote">On Tue, May 24, 2011 at 11:45 PM, Richard O'Keefe <span dir="ltr"><<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
On 25/05/2011, at 7:09 AM, Jack Moffitt wrote:<br>
> QueryPerformanceCounter() is pretty readily available as far as I<br>
> remember. Here's something Google brought up for implementing<br>
> microsecond timers with it:<br>
> <a href="http://www.decompile.com/cpp/faq/windows_timer_api.htm" target="_blank">http://www.decompile.com/cpp/faq/windows_timer_api.htm</a><br>
<br>
</div>Er, there's a problem with the performance counters, isn't there?<br>
now() is supposed to give you a clock, something that ticks<br>
regularly.<br>
The performance counters count events in the CPU, and today's<br>
power-sensitive CPUs do things like scaling back the CPU clock<br>
frequency when they think they aren't busy.<br>
<br>
I know people keep telling me that time monitoring using cpu<br>
cycle counters doesn't work any more; I can't say of my own knowledge<br>
whether they are right.<br></blockquote></div><br>According to msdn, QueryPerformanceCounter() is the solution to problems like RDTSC slipping in power management ( <a href="http://msdn.microsoft.com/en-us/library/ee417693%28v=vs.85%29.aspx">http://msdn.microsoft.com/en-us/library/ee417693%28v=vs.85%29.aspx</a> circa 2005), but some later discussions ( <a href="http://www.red-gate.com/supportcenter/Content?p=ANTS%20Performance%20Profiler&c=ANTS_Performance_Profiler\knowledgebase\app_speedstep.htm">http://www.red-gate.com/supportcenter/Content?p=ANTS%20Performance%20Profiler&c=ANTS_Performance_Profiler\knowledgebase\app_speedstep.htm</a> ) suggest that newer power management techniques (such as AMD cool'n'quiet) could defeat the efforts of that timer to maintain a steady beat. It's hard to tell if that has been addressed by Microsoft or not since then.<br>
<br>I'm really at a loss as to what the right solution here could be. I have trouble imagining there isn't one, but I'm not well-versed enough in the architecture to know where else to look.<br><br>I do know that right now there is a higher resolution timer available than what now/0 uses, but I'm not clear on what the performance penalty of os:timestamp/0 is in comparison, and I wouldn't know how to properly measure it.<br>