diff --git a/tests/playground/Makefile b/tests/playground/Makefile index e53ba77a39..141a85dcc5 100644 --- a/tests/playground/Makefile +++ b/tests/playground/Makefile @@ -4,8 +4,8 @@ BENCH=ulimit -s unlimited && bench CROSS_BENCHES = binarytrees deriv expr_const_folding rbmap # basic version usable without Nix -#CROSS_CATS = .lean .hs .gc.hs .llvm.hs .ml .gc.ml -CROSS_CATS = .lean .gcc.lean .hs .gc.hs .llvm.hs .llvm.gc.hs .ml .gc.ml .flambda.ml +#CROSS_CATS = .lean .perf.lean .hs .gc.hs .perf.hs .llvm.hs .ml .gc.ml .perf.ml +CROSS_CATS = .lean .lean.perf .gcc.lean .hs .gc.hs .hs.perf .llvm.hs .ml .gc.ml .ml.perf .flambda.ml GHC_FLAGS = -O3 OCAML_FLAGS = -O3 @@ -72,6 +72,9 @@ bench/%gc.hs.bench: %hs.out | bench bench/%gc.ml.bench: %gc.ml.out | bench ulimit -s unlimited && OCAML_INSTR_FILE=$@ time -ao $@ -f '%e' ./$< $(BENCH_PARAMS) +bench/%.perf.bench: %.out | bench + ulimit -s unlimited && perf stat -e cache-references,cache-misses,branches,branch-misses -o $@ ./$< $(BENCH_PARAMS) + # fork() breaks instrumentation bench/binarytrees.gc.ml.bench: touch $@ diff --git a/tests/playground/report.py b/tests/playground/report.py index f00889f2cd..71774e9cce 100755 --- a/tests/playground/report.py +++ b/tests/playground/report.py @@ -3,6 +3,7 @@ import ast import json import os +import re import sys def read(bench, cat): @@ -33,15 +34,24 @@ def pp_gc_ml(bench, cat, norm): gc_nanos += int(data[2]) - int(data[1]) return f"{gc_nanos*1e-9/wall_secs:.0%}" +def pp_perf(bench, cat, norm): + stat = open(f"bench/{bench}{cat}.bench", 'r').read() + #misses_percent = float(re.search("([0-9.]+) % of all cache refs", stat)[1]) / 100 + misses = int(re.search("([0-9,]+)\s+cache-misses", stat)[1].replace(',', '')) + secs = float(re.search("([0-9.]+) seconds time elapsed", stat)[1]) + return f"{misses*1e-6/secs:.3f}" + CATBAG = { '.lean': ("Lean", pp_bench), '.gcc.lean': ("Lean+GCC9", pp_bench), + '.lean.perf': ("cache misses (1M/s)", pp_perf), '.hs': ("GHC", pp_bench), '.gc.hs': ("%GC", pp_gc_hs), + '.hs.perf': ("cache misses", pp_perf), '.llvm.hs': ("GHC -fllvm", pp_bench), - '.llvm.gc.hs': ("%GC", pp_gc_hs), '.ml': ("OCaml", pp_bench), '.gc.ml': ("%GC", pp_gc_ml), + '.ml.perf': ("cache misses", pp_perf), '.flambda.ml': ("OCaml+Flambda", pp_bench), }