-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrender.py
More file actions
50 lines (36 loc) · 940 Bytes
/
Copy pathrender.py
File metadata and controls
50 lines (36 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# /// script
# dependencies = [
# "matplotlib",
# "pandas"
# ]
# ///
import matplotlib.pyplot as plt
import sys
import json
import pandas as pd
data_file = sys.argv[1]
output_file = sys.argv[2]
title = sys.argv[3]
with open(data_file,'r') as fp:
timings = json.load(fp)
names = []
mu = []
sigma = []
for impl in timings['results']:
names.append(impl['command'])
mu.append(impl['mean'])
sigma.append(impl['stddev'])
df = pd.DataFrame({"name":names, "means":mu, "var":sigma}).set_index("name").reindex(names)
fig, ax = plt.subplots(figsize=(12, 6))
# Example data
hbars = ax.barh(df.index, df['means'], xerr=df['var'], align='center')
ax.invert_yaxis()
ax.set_xlabel('Time (ms)')
ax.set_title(title)
ax.grid(which="minor", color="0.9")
ax.xaxis.grid()
ax.margins(0.2,0.1)
ax.set_xscale("log")
ax.bar_label(hbars, padding = 8, fmt=lambda s: f'{s*1000:.2f} ms')
ax.set_axisbelow(True)
plt.savefig(output_file)