
"Patrick Loney" <Patrick.Loney@InteractiveTS.com> writes:
I'm using the following code to trace the time different sections of code take to execute (where btime = boost::posix_time):
btime::to_iso_extended_string( btime::microsec_clock::universal_time() )
I am finding that a lot of things are happening simultaneously (or rather in the same micro second) and then some random operation (perhaps the declaration of a variable, perhaps a DB query) will take 0.015 (ish) seconds.
The software is running on windows XP service pack 2.
Is there a known resolution issue using the microsec_clock on windows xp?
Windows reports times to a precision of 100ns, but typically the system clock has a resolution of about 10-15ms, so it is common to see 10-15ms jumps in the time. Windows Multimedia timers can give you a time period of 1ms if your hardware supports it. The only other alternative is QueryPerformanceCounter, which has a system-specific frequency (which you can get from QueryPerformanceFrequency). Some system device drivers have a bug which means QueryPerformanceCounter values vary between CPUs, and are therefore unreliable for really high precision timing unless you set the processor affinity for the thread. Anthony -- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL