Resolution of core.time.Duration...

Alexander aldem+dmars at nk7.net
Tue May 17 08:18:36 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.

/Alexander


More information about the Digitalmars-d mailing list