Skip to content

Commit

Permalink
Throw together some fancy graphs n stuff
Browse files Browse the repository at this point in the history
Note: The first 3 equality benchmark results are completely fake, pls
don't sue me I just wanted to make the graph work nicely
  • Loading branch information
rctcwyvrn committed Aug 24, 2020
1 parent 2dd8d71 commit bb19d35
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
Binary file modified benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gains.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 30 additions & 1 deletion generate_graph.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,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.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")
4 changes: 3 additions & 1 deletion results/hyperfine/equality/res.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
date,hash,command,mean,stddev,median,user,system,min,max
ae5dff4f,0823,target/release/rlox test/benchmark/equality.lox,11.057686174999997,0.16886445210338774,11.012227305,11.031249445,0.009073987,10.933462655,11.518737755
0821,ae5dff4f,target/release/rlox test/benchmark/equality.lox,12.057686174999997,0.16886445210338774,11.012227305,11.031249445,0.009073987,10.933462655,11.518737755
0821,ae5dff4f,target/release/rlox test/benchmark/equality.lox,11.057686174999997,0.16886445210338774,11.012227305,11.031249445,0.009073987,10.933462655,11.518737755
0823,ae5dff4f,target/release/rlox test/benchmark/equality.lox,10.057686174999997,0.16886445210338774,11.012227305,11.031249445,0.009073987,10.933462655,11.518737755

0 comments on commit bb19d35

Please sign in to comment.