RE: [GD-Windows] More timer fun! (sorry for revisit!)
Brought to you by:
vexxed72
From: Jon W. <hp...@mi...> - 2002-12-25 18:34:50
|
> Actually the best implementation is to insert a cpuid instruction before > rdtsc, to prevent out-of-sequence execution from ruining the results. You're right! I usually don't go down to the 40-cycle tight-loop timing case, though, preferring to stay at the level where I'm trying to structure the working set of some algorithm so it'll fit in L1, so I seldom need to really serialize. It's unfortunate that the CPUID trashes the other registers, though. It's even more unfortunate that all serializing instructions also cause pending memory writes to complete. If you're trying to time the instruction to know how much to subtract (if you're measuring a very small segment) then whatever was happening in the memory subsystem at that time may greatly affect your timing compensation data! Maybe you have to run your really tight timing code in ring 0 so you can use some less-intrusive serializing instructions... You can either get good precision, or low overhead. Is this Heisenberg in action? :-) Cheers, / h+ |