> Having trouble getting microsecond granularity using Poco::Stopwatch. Documentation says it has microsecond granularity. And the resolution() method returns 1000000 as expected, however the values returned from elapsed() are rounded to milliseconds.
> Running in Vista 32-bit on a P4 (830). Probably has something to do with poor granularity of system timers under Windows, but can anyone shed any light on what the expected behavior should be or if there's any way I CAN get microsecond resolution with the Poco library?
Stopwatch internally uses Timestamp, which explicitly states in the documentation that the microsecond is theoretical resolution. Admittedly, Stopwatch documentation is deceptive.
Here's a MSDN article on the topic:
Quote from the article:
- Code: Select all
When you ask how to obtain the system time with a better resolution than 10 ms you'll probably get an answer like: use performance counters and synchronize the performance counter value to the instant the system time changes.
The Poco code you want to look into is Timestamp::update() (obviously, the win32 portion). If you succeed in achieving better results, please consider contributing the code.