Resolution of core.time.Duration...

Jonathan M Davis jmdavisProg at gmx.com
Tue May 17 16:18:14 PDT 2011


> On 17.05.2011 20:06, Jonathan M Davis wrote:
> > StopWatch uses a mononotonic clock.
> 
> Monotonic clock is not CPU-usage-bound - it is in sync with wall-time, so
> problem on busy systems remains.

A monotonic clock is as good as you're going to get for accurate stopwatch 
functionality. The system cannot possibly do any better than that. Context 
switching can always get in the way. Increasing precision doesn't help that. 
And since StopWatch uses TickDuration, it has the highest precision that the 
the sytem has anyway (whatever its clock tick is) rather than hnsecs. I don't 
understand what your concern is. StopWatch is using the highest precision, 
most accurate clock that it can, and there's no way to stop issues with 
context switching. What more do you expect it to do? You're talking like 
there's something wrong with std.datetime's benchmarking functionality, and as 
far as I know, it has the best that is possible as far as timing accuracy 
goes.

- Jonathan M Davis


More information about the Digitalmars-d mailing list