Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
more stable timings
Browse files Browse the repository at this point in the history
- use best of 10 runs

- align and cleanup output
  • Loading branch information
MartinNowak committed Dec 27, 2014
1 parent f28a4c4 commit 459275c
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions benchmark/runbench.d
Expand Up @@ -5,7 +5,7 @@
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Authors: Martin Nowak
*/
import std.ascii, std.datetime, std.exception, std.file, std.path,
import std.ascii, std.exception, std.file, std.path,
std.process, std.regex, std.stdio, std.string, std.typecons;

// cmdline flags
Expand All @@ -32,27 +32,33 @@ void runTest(string pattern, string dmd, string dflags)
}
}

immutable bindir = absolutePath("bin");

foreach(ref src; sources)
{
writeln("COMPILING ", src);
auto bin = buildPath(absolutePath("bin"), src.chompPrefix("./").chomp(".d"));
auto bin = buildPath(bindir, src.chompPrefix("./").chomp(".d"));
auto cmd = std.string.format("%s %s -op -odobj -of%s %s", dmd, dflags, bin, src);
runCmd(cmd);
src = bin;
}

foreach(bin; sources)
{
StopWatch sw;

writeln("RUNNING ", baseName(bin));
sw.start;
runCmd(bin);
sw.stop;
import std.datetime, std.algorithm : min;
auto sw = StopWatch(AutoStart.yes);
auto dur = Duration.max;

auto p = sw.peek;
writefln(" took %s.%s sec.", p.seconds, p.msecs % 1000);
sw.reset;
stdout.writef("RUNNING %-20s", bin.relativePath(bindir));
stdout.flush();
foreach (_; 0 .. 10)
{
sw.reset;
runCmd(bin);
dur = min(dur, cast(Duration)sw.peek);
}
auto res = dur.split!("seconds", "msecs");
writefln(" %s.%03s s", res.seconds, res.msecs);
}
}

Expand Down

0 comments on commit 459275c

Please sign in to comment.