From 27257d14131c7713254cd23d23065d44bc7d56e6 Mon Sep 17 00:00:00 2001 From: Nathan Sashihara <21227491+n8sh@users.noreply.github.com> Date: Wed, 13 Jun 2018 16:19:17 -0400 Subject: [PATCH] Revert "Add dontOptimizeAway to std.datetime.stopwatch" --- std/datetime/stopwatch.d | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/std/datetime/stopwatch.d b/std/datetime/stopwatch.d index 55c98df3b91..50874743c0f 100644 --- a/std/datetime/stopwatch.d +++ b/std/datetime/stopwatch.d @@ -393,6 +393,7 @@ private: auto timeElapsed = MonoTime.currTime - before; } + /++ Benchmarks code for speed assessment and comparison. @@ -412,25 +413,11 @@ Duration[fun.length] benchmark(fun...)(uint n) Duration[fun.length] result; auto sw = StopWatch(AutoStart.yes); - static foreach (i, unused; fun) + foreach (i, unused; fun) { sw.reset(); foreach (_; 0 .. n) - { - static if (!is(typeof(fun[i]()) == void)) - { - // avoid optimization - asm - { - call [fun + i]; - ret; - } - } - else - { - fun[i](); - } - } + fun[i](); result[i] = sw.peek(); }