Overview
Features
Download
Documentation
Community
Add-Ons & Services

Timestamp granularity

Please post support and help requests here.

Timestamp granularity

Postby wseguin » 26 Jul 2007, 18:01

Hi,

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?

Thanks,

Wayne
wseguin
 
Posts: 4
Joined: 05 Jun 2007, 20:40

Re: Timestamp granularity

Postby alex » 26 Jul 2007, 19:32

> 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:

http://msdn.microsoft.com/msdnmag/issues/04/03/HighResolutionTimer/

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.

Alex
alex
 
Posts: 1086
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests