Benchmarking Time Unit

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 1 13:32:28 PDT 2016


On Tuesday, November 01, 2016 20:21:32 Nordlöw via Digitalmars-d-learn 
wrote:
> On Tuesday, 1 November 2016 at 20:19:31 UTC, Nordlöw wrote:
> > MonoTime has about 5-10 % fluctuations on my laptop. Is this as
> > good as it gets?
>
> Is
>
> https://dlang.org/phobos/core_time.html#.ClockType.threadCPUTime
>
> what I should use if I'm on Linux?

The default (ClockType.normal) unless you have a really good reason to do
otherwise. And if you're most worried about having high precision (as is
presumably the case if you're benchmarking), ClockType.normal is the best
you get on Linux. You can use ClockType.precise, but on Linux, it's the same
as ClockType.normal. It's just FreeBSD that has a more precise clock. And
really, ClockType.normal is plenty precise. IIRC, it's usually about a tick
per microsecond on Linux.

- Jonathan M Davis




More information about the Digitalmars-d-learn mailing list