1import os 2import os.path 3import json 4 5comparisons = [] 6 7for (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 22comparisons.sort(key=lambda x: x[1]) 23longest_name = max(len(c[0]) for c in comparisons) 24for (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}") 31