-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_graph.py
58 lines (50 loc) · 1.45 KB
/
generate_graph.py
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
51
52
53
54
55
56
57
58
import matplotlib.pyplot as plt
import csv
import glob
import numpy as np
legend = []
all_gains = []
for file in glob.glob("./results/hyperfine/*/*.csv"):
dates = []
means = []
gains = []
name = file.split("/")[-2]
with open(file) as csv_file:
reader = csv.DictReader(csv_file)
last_date = None
last_mean = None
for row in reader:
means.append(float(row['mean']))
if last_mean != None:
percent_gain = 100 * (last_mean - float(row['mean'])) / last_mean
gains.append(percent_gain)
if int(row['date']) == last_date:
dates.append(last_date + 0.1)
else:
dates.append(int(row['date']))
last_date = int(row['date'])
last_mean = float(row['mean'])
print(f"Plotting {name} | {dates} {means}")
# plt.plot(dates, means)
plt.plot(means)
legend.append(name)
all_gains.append([name, gains])
print("Saving plot")
plt.legend(legend)
#plt.show()
plt.savefig("benchmarks.png")
plt.clf()
plt.figure(figsize=(10,50))
ind = np.arange(len(dates)-1, step=1)
plots = []
names = []
for i, (name, gains) in enumerate(all_gains):
print(f"Plotting gains {name} | {gains}")
#p = plt.bar(ind, gains)
plt.subplot(10, 1, i+1)
plt.title(name)
plt.ylim(-50,50)
plt.xticks(ind, dates)
p = plt.bar(ind, gains, width=0.1)
plots.append(p[0])
plt.savefig("gains.png")