From 0bc5cd38d4387e2624b8c67db0b5e282fd486421 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 22 Nov 2014 13:02:01 -0800 Subject: Revised benchmark procedure. Now we take the difference of the time to process the input and the time to run with no input. This compensates for slow startup time in dynamic languages. See comments on 2dcef8a --- bench/stats.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'bench') diff --git a/bench/stats.py b/bench/stats.py index 3298099..c244b41 100644 --- a/bench/stats.py +++ b/bench/stats.py @@ -3,7 +3,15 @@ import sys import statistics -values = [ float(x) for x in sys.stdin.readlines()] +def pairs(l, n): + return zip(*[l[i::n] for i in range(n)]) + +# data comes in pairs: +# n - time for running the program with no input +# m - time for running it with the benchmark input +# we measure (m - n) + +values = [ float(y) - float(x) for (x,y) in pairs(sys.stdin.readlines(),2)] print("mean = %.4f, median = %.4f, stdev = %.4f" % (statistics.mean(values), statistics.median(values), -- cgit v1.2.3