On 11/1/16 4:19 PM, Nordlöw wrote:
On Tuesday, 1 November 2016 at 18:39:01 UTC, Jonathan M Davis wrote:
Alternatively, you can always do something like

immutable before = MonoTime.currTime();
// do stuf...
immutable after = MonoTime.currTime();
Duration timeSpent = after - before;

MonoTime has about 5-10 % fluctuations on my laptop. Is this as good as
it gets?

This is not clear. What is this a percentage of?

If you are hoping that you run code and the total time taken is going to be consistent within a few nanoseconds, then I'm sorry to say it's not going to happen. If you mean it's varying by 5-10 seconds, then this is a different story, but still could be expected.

MonoTime is going to be very accurate. What isn't true is that on a laptop being used with a non-realtime OS, you will have exactly consistent results for userspace programs.

As Jonathan mentioned, the way around this is to average several runs of the same test.

-Steve

Reply via email to