-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add python script to format benchmark output; remove unneeded compile…
… flag for clang
- Loading branch information
1 parent
9312201
commit 3965b7e
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Reads output of `cargo bench` from stdin | ||
Prints markdown-formatter tables on stdout | ||
""" | ||
|
||
from collections import defaultdict | ||
from tabulate import tabulate | ||
from sys import argv | ||
|
||
BENCHMARKED_LIBS = argv[1:] | ||
|
||
all_bench_data: defaultdict = defaultdict(lambda: defaultdict(defaultdict)) | ||
|
||
while True: | ||
try: | ||
bench_res_line = input() | ||
except EOFError: | ||
break | ||
if not bench_res_line.startswith("test bench_"): | ||
continue | ||
single_bench_res = bench_res_line.split() | ||
[func, ftype, lib] = single_bench_res[1].removeprefix("bench_").rsplit("_", 2) | ||
if lib not in BENCHMARKED_LIBS: | ||
continue | ||
runtime = single_bench_res[4] | ||
all_bench_data[ftype][func][lib] = int(runtime.replace(",", "")) | ||
|
||
|
||
for ftype, bench_data in all_bench_data.items(): | ||
all_functions = sorted(bench_data.keys()) | ||
table = [ | ||
[f"`{func}`"] + [bench_data[func].get(lib, None) for lib in BENCHMARKED_LIBS] | ||
for func in all_functions | ||
] | ||
table = [ | ||
row[:1] | ||
+ [ | ||
f"`{res:,}`" if res == min(bench_data[func].values()) else f"{res:,}" | ||
for res in row[1:] | ||
] | ||
for func, row in zip(all_functions, table) | ||
] | ||
print( | ||
tabulate(table, headers=[ftype] + BENCHMARKED_LIBS, tablefmt="github"), | ||
end="\n\n", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters