Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions benchmark/runbench.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ struct Config
uint repeat = 10;
}

string runCmd(string cmd, bool verbose)
string runCmd(string cmd, bool verbose, in char[] workDir = null)
{
import std.exception : enforce;
import std.process : executeShell;
import std.process : executeShell, Config;

if (verbose) writeln(cmd);
auto res = executeShell(cmd);
auto res = executeShell(cmd, null, Config.none, size_t.max, workDir);
enforce(res.status == 0, res.output);
return res.output;
}
Expand Down Expand Up @@ -72,13 +72,15 @@ void runTests(Config cfg)

import std.parallelism : parallel;
immutable bindir = absolutePath("bin", cwd);
immutable objdir = absolutePath("obj", cwd);

foreach(ref src; sources.parallel(1))
{
writeln("COMPILING ", src);
version (Windows) enum exe = "exe"; else enum exe = "";
auto bin = buildPath(bindir, src.relativePath(cwd).setExtension(exe));
auto cmd = std.string.format("%s %s -op -odobj -of%s %s", cfg.dmd, cfg.dflags, bin, src);
auto obj = buildPath(objdir, src.relativePath(cwd).setExtension(exe));
auto cmd = std.string.format("%s %s -op -od%s -of%s %s", cfg.dmd, cfg.dflags, obj, bin, src);
if (auto ex = src in extra_sources)
cmd ~= " -I" ~ src[0..$-2] ~ ".extra" ~ *ex;
runCmd(cmd, cfg.verbose);
Expand Down Expand Up @@ -109,7 +111,7 @@ void runTests(Config cfg)
foreach (_; 0 .. cfg.repeat)
{
sw.reset;
auto output = runCmd(cmd, cfg.verbose);
auto output = runCmd(cmd, cfg.verbose, cwd);
Copy link
Contributor

@wilzbach wilzbach Jan 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh - I didn't see that cwd is already set to exactly this.

auto dur = cast(Duration)sw.peek;

auto parts = dur.split!("seconds", "msecs");
Expand Down