Skip to content

Commit

Permalink
add a script to automatically make a markdown table from the benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
KillingSpark committed Feb 27, 2020
1 parent 750d69d commit 09e410f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion benches/marshal_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ fn criterion_benchmark(c: &mut Criterion) {
make_dbus_bytestream_message(&parts, false);
})
});
c.bench_function("marshal_dbus_message_parser", |b| {
c.bench_function("marshal_dbus_msg_parser", |b| {
b.iter(|| {
make_dbus_message_parser_message(&parts, false);
})
Expand Down
57 changes: 57 additions & 0 deletions tools/make_table.py
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)

0 comments on commit 09e410f

Please sign in to comment.