forked from KillingSpark/rust-dbus-comparisons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a script to automatically make a markdown table from the benchmarks
- Loading branch information
1 parent
750d69d
commit 09e410f
Showing
2 changed files
with
58 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
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,57 @@ | ||
#! /bin/python3 | ||
|
||
import os | ||
|
||
stream = os.popen('bash -c "cargo bench | grep time"') | ||
#stream = os.popen('bash -c "cargo bench rustbus | grep time"') | ||
output = stream.read() | ||
|
||
table_lines = [] | ||
results = {} | ||
benches = [] | ||
|
||
def filter_empty(var): | ||
return len(var) != 0 | ||
|
||
lines = output.split("\n") | ||
for line in lines: | ||
if len(line) == 0: | ||
continue | ||
|
||
words = line.split(" ") | ||
words = list(filter(filter_empty, words)) | ||
|
||
name_split = words[0].split("_") | ||
benchname = name_split[0] | ||
libname = "_".join(name_split[1:]) | ||
timings = " ".join(words[2:]) | ||
|
||
if not benchname in benches: | ||
benches.append(benchname) | ||
|
||
if not libname in results: | ||
results[libname] = {} | ||
results[libname][benchname] = timings | ||
|
||
for libname in results: | ||
print(libname) | ||
line = "|" + libname + "|" | ||
for bench in benches: | ||
libbenches = results[libname] | ||
if bench in libbenches: | ||
line += libbenches[bench] | ||
line += "|" | ||
|
||
table_lines.append(line) | ||
|
||
header = "|Library|" | ||
for bench in benches: | ||
header += bench + "|" | ||
print(header) | ||
header = "|-|" | ||
for bench in benches: | ||
header += "-|" | ||
print(header) | ||
|
||
for line in table_lines: | ||
print(line) |