From 204911393519ab42c2ab6aa48b3aaa8c1158526c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 14 Feb 2017 15:34:00 +0100 Subject: [PATCH] Benchmark script: use median AND mean of compile time --- scripts/benchmarkCompile.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/benchmarkCompile.py b/scripts/benchmarkCompile.py index 6f647511..a3fc32cd 100755 --- a/scripts/benchmarkCompile.py +++ b/scripts/benchmarkCompile.py @@ -13,6 +13,9 @@ def median(lst): else: return (lst[mid - 1] + lst[mid]) / 2.0 +def mean(lst): + return float(sum(lst)) / max(len(lst), 1) + compiler_path = '' main_file = r''' @@ -69,7 +72,8 @@ def link_files(): return end_t - start_t def benchmark(func): - return median([func() for i in range(10)]) + results = [func() for i in range(10)] + return mean(results), median(results) def char_range(start, end): for c in range(ord(start), ord(end)): @@ -130,8 +134,8 @@ if args.generate_files: print('Time needed for ...') if args.benchmark_kind in ('all', 'main'): - print(' ... compiling main: {:.2f} s'.format(benchmark(compile_main))) + print(' ... compiling main, mean: {:.2f}, median: {:.2f} s'.format(*benchmark(compile_main))) if args.benchmark_kind in ('all', 'files'): - print(' ... compiling test files: {:.2f} s'.format(benchmark(compile_files))) + print(' ... compiling test files, mean: {:.2f}, median: {:.2f} s'.format(*benchmark(compile_files))) if args.benchmark_kind in ('all', 'link'): - print(' ... linking everything: {:.2f} s'.format(benchmark(link_files))) + print(' ... linking everything, mean: {:.2f}, median: {:.2f} s'.format(*benchmark(link_files)))