Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Benchmark script: use median AND mean of compile time

Commit
204911393519ab42c2ab6aa48b3aaa8c1158526c
Author
Martin Hořeňovský ·
Parents
0837132ce305

Files · Download .tar.gz

Changes

 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)))