| 1 |
import os |
| 2 |
import os.path |
| 3 |
import json |
| 4 |
|
| 5 |
comparisons = [] |
| 6 |
|
| 7 |
for (root, _dirs, files) in os.walk('target/criterion'): |
| 8 |
for file in files: |
| 9 |
if file == 'estimates.json' and root.endswith( |
| 10 |
'new') and 'TinyVec' in root: |
| 11 |
path = os.path.join(root, file) |
| 12 |
|
| 13 |
bench_name = path.split('/')[3] |
| 14 |
tinyvec_time = json.load(open(path))['mean']['point_estimate'] |
| 15 |
|
| 16 |
path = path.replace('TinyVec', 'SmallVec') |
| 17 |
|
| 18 |
smallvec_time = json.load(open(path))['mean']['point_estimate'] |
| 19 |
|
| 20 |
comparisons.append((bench_name, tinyvec_time / smallvec_time)) |
| 21 |
|
| 22 |
comparisons.sort(key=lambda x: x[1]) |
| 23 |
longest_name = max(len(c[0]) for c in comparisons) |
| 24 |
for (name, ratio) in comparisons: |
| 25 |
# Undo the criterion name mangling |
| 26 |
name = name.replace('_[', '<[') |
| 27 |
name = name.replace(']___', ']>::') |
| 28 |
|
| 29 |
name = name.ljust(longest_name) |
| 30 |
print(f"{name} {ratio:.2f}") |