digitalmars.D.learn - Benchmarking Time Unit
- =?UTF-8?B?Tm9yZGzDtnc=?= (3/3) Nov 01 2016 Which way of measuring time in std.datetime should I used if I
- Jonathan M Davis via Digitalmars-d-learn (16/19) Nov 01 2016 That's what std.datetime.benchmark is for, though unfortunately, it stil...
- =?UTF-8?B?Tm9yZGzDtnc=?= (4/9) Nov 01 2016 MonoTime has about 5-10 % fluctuations on my laptop. Is this as
- =?UTF-8?B?Tm9yZGzDtnc=?= (4/6) Nov 01 2016 Is
- Jonathan M Davis via Digitalmars-d-learn (10/16) Nov 01 2016 The default (ClockType.normal) unless you have a really good reason to d...
- Jonathan M Davis via Digitalmars-d-learn (10/20) Nov 01 2016 How precise it is depends on your system. MonoTime uses the system's
- Steven Schveighoffer (12/21) Nov 01 2016 This is not clear. What is this a percentage of?
- =?UTF-8?B?Tm9yZGzDtnc=?= (7/11) Nov 01 2016 It percentage of execution time.
- Stefan Koch (4/16) Nov 01 2016 I supposed you could not have done it with less templates :)
- Steven Schveighoffer (3/10) Nov 03 2016 2ms variance is not horrendous or unexpected on a non-realtime system.
- Steven Schveighoffer (3/14) Nov 03 2016 Put another way, this is not a symptom of MonoTime having issues.
Which way of measuring time in std.datetime should I used if I want to benchmark a function by the amount of time spent in the current thread, not wall-clock time?
Nov 01 2016
On Tuesday, November 01, 2016 16:53:51 Nordlöw via Digitalmars-d-learn wrote:Which way of measuring time in std.datetime should I used if I want to benchmark a function by the amount of time spent in the current thread, not wall-clock time?That's what std.datetime.benchmark is for, though unfortunately, it still uses core.time.TickDuration rather using core.time.MonoTime and core.time.Duration. Alternatively, you can always do something like immutable before = MonoTime.currTime(); // do stuf... immutable after = MonoTime.currTime(); Duration timeSpent = after - before; though that just times how long something took rather than running it over and over again like benchmark does. I really need to get replacements for the TickDuration-related stuff in std.datetime into std.experimental so that we can move towards replacing it and finally getting rid of TickDuration, but I haven't gotten to it yet. - Jonathan M Davis
Nov 01 2016
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?
Nov 01 2016
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?
Nov 01 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: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 DavisMonoTime 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?
Nov 01 2016
On Tuesday, November 01, 2016 20:19:31 Nordlöw via Digitalmars-d-learn wrote:On Tuesday, 1 November 2016 at 18:39:01 UTC, Jonathan M Davis wrote:How precise it is depends on your system. MonoTime uses the system's monotonic clock at whatever precision it has. And even if it's perfectly precise, you're going to see fluctuations in how long it takes your code to run, since it's not the only thing running on your computer. That's part of why std.datetime.benchmark runs the function over and over again rather than only running it only once. That way, you get the average performance rather than the performance for a single run. - Jonathan m DavisAlternatively, 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?
Nov 01 2016
On 11/1/16 4:19 PM, Nordlöw wrote:On Tuesday, 1 November 2016 at 18:39:01 UTC, Jonathan M Davis wrote: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. -SteveAlternatively, 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?
Nov 01 2016
On Tuesday, 1 November 2016 at 20:54:34 UTC, Steven Schveighoffer wrote:It percentage of execution time. 15 ms +- 2 ms That seems doesn't look like what you describe. Benchmark code here: https://github.com/nordlow/phobos-next/blob/master/src/benchmarkAppend.dMonoTime 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?
Nov 01 2016
On Tuesday, 1 November 2016 at 22:55:36 UTC, Nordlöw wrote:On Tuesday, 1 November 2016 at 20:54:34 UTC, Steven Schveighoffer wrote:I supposed you could not have done it with less templates :) Since you are hitting gc-code all the time it should be expected to have varing times.It percentage of execution time. 15 ms +- 2 ms That seems doesn't look like what you describe. Benchmark code here: https://github.com/nordlow/phobos-next/blob/master/src/benchmarkAppend.dMonoTime 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?
Nov 01 2016
On 11/1/16 6:55 PM, Nordlöw wrote:On Tuesday, 1 November 2016 at 20:54:34 UTC, Steven Schveighoffer wrote:2ms variance is not horrendous or unexpected on a non-realtime system. -SteveIt percentage of execution time. 15 ms +- 2 msMonoTime 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?
Nov 03 2016
On 11/3/16 9:03 AM, Steven Schveighoffer wrote:On 11/1/16 6:55 PM, Nordlöw wrote:Put another way, this is not a symptom of MonoTime having issues. -SteveOn Tuesday, 1 November 2016 at 20:54:34 UTC, Steven Schveighoffer wrote:2ms variance is not horrendous or unexpected on a non-realtime system.It percentage of execution time. 15 ms +- 2 msMonoTime 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?
Nov 03 2016