Resolution of core.time.Duration...

Jonathan M Davis jmdavisProg at gmx.com
Tue May 17 11:06:38 PDT 2011


> On 17.05.2011 16:45, Steven Schveighoffer wrote:
> > The structures have used nanoseconds for over 10 years (I think
> > gettimeofday used it back in the 90s!), so the reason for using it was
> > likely for future compatibility (clearly nanosecond timing wasn't
> > possible back then). It looks like the future is now, so it's good to
> > have that resolution.
> 
> As to gettimeofday() - it is using timeval, which has 1µs resolution -
> still quite good for most applications.
> 
> > As for measuring time, yes, it would be good to use a higher precision
> > timer. And in fact, std.datetime.StopWatch does just that.
> 
> Just in case - StopWatch is used in benchmarking functions while
> measuring wall-clock time, and this may produce incorrect results on busy
> systems when benchmarking CPU-intensive code.

StopWatch uses a mononotonic clock.

- Jonathan M Davis


More information about the Digitalmars-d mailing list