summaryrefslogtreecommitdiff
path: root/bench/runbench.myr
diff options
context:
space:
mode:
Diffstat (limited to 'bench/runbench.myr')
-rw-r--r--bench/runbench.myr59
1 files changed, 0 insertions, 59 deletions
diff --git a/bench/runbench.myr b/bench/runbench.myr
deleted file mode 100644
index ea69f83..0000000
--- a/bench/runbench.myr
+++ /dev/null
@@ -1,59 +0,0 @@
-use std
-
-const Nsamp = 10
-
-const main = {args : byte[:][:]
- var tot : flt64
-
- std.put("Running benchmarks: {} samples per binary\n", Nsamp);
- tot = 0.0;
- for arg : args[1:]
- tot = tot + timeit(arg)
- ;;
- std.put("total:\t{}s\n", tot);
-}
-
-const timeit = {prog -> flt64
- var avg, m, d, x, n : flt64
-
- avg = 0.0;
- m = 0.0;
- n = 0.0;
- for var i = 0; i < Nsamp; i++
- n = n + 1.0;
- x = run(prog);
- d = (x - avg);
- avg = avg + d/n;
- m = m + d*(x - avg);
- ;;
- std.put("{}:\t{}s (σ^2: {})\n", prog, avg, m/(n-1.0));
- -> avg;
-}
-
-const run = {prog -> flt64
- var infd, outfd
- var pid
- var tm
-
- tm = std.now()
- pid = std.fork();
- if pid < 0
- std.fatal("Could not fork\n");
- elif pid == 0
- infd = std.try(std.open("/dev/zero", std.Ordonly))
- outfd = std.try(std.open("/dev/null", std.Owronly))
- std.try(std.dup2(infd, 0))
- std.try(std.dup2(outfd, 1))
- std.execv(prog, [prog][:])
- std.fatal("Failed to exec\n")
- else
- match std.wait(pid)
- | `std.Wfailure: std.fatal("could not wait\n")
- | `std.Waiterror: std.fatal("running benchmark failed\n")
- | `std.Wsignalled: std.fatal("running benchmark failed\n")
- | `std.Wsuccess: /* nothing */
- ;;
- ;;
- -> (std.now() - tm : flt64) / 1_000_000.0
-}
-