2018-04-05 22:07:33 +00:00
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import numpy as np
|
|
|
|
import json
|
|
|
|
import sys
|
|
|
|
|
|
|
|
plt.rcdefaults()
|
|
|
|
fig, ax = plt.subplots(constrained_layout=True, figsize=(8, 8))
|
|
|
|
|
|
|
|
with open(sys.argv[-2]) as fp:
|
|
|
|
content = json.load(fp)
|
|
|
|
|
|
|
|
results = []
|
|
|
|
for k, v in content.items():
|
2020-06-28 18:24:40 +00:00
|
|
|
results.append((k, v["firefox"] / v["native"], v["chrome"] / v["native"]))
|
2018-04-05 22:07:33 +00:00
|
|
|
results.sort(key=lambda x: x[1], reverse=True)
|
|
|
|
|
|
|
|
names = [x[0] for x in results]
|
2018-07-09 19:09:49 +00:00
|
|
|
firefox = [x[1] for x in results]
|
|
|
|
chrome = [x[2] for x in results]
|
2018-04-05 22:07:33 +00:00
|
|
|
|
2018-07-09 19:09:49 +00:00
|
|
|
width = 0.35
|
2018-04-05 22:07:33 +00:00
|
|
|
y_pos = np.arange(len(results))
|
2020-06-28 18:24:40 +00:00
|
|
|
ax.barh(y_pos, firefox, width, color="#ff9400", label="firefox")
|
|
|
|
ax.barh(y_pos + width, chrome, width, color="#45a1ff", label="chrome")
|
2018-07-09 19:09:49 +00:00
|
|
|
ax.set_yticks(y_pos + width / 2)
|
2018-04-05 22:07:33 +00:00
|
|
|
ax.set_yticklabels(names)
|
|
|
|
ax.invert_yaxis()
|
2020-06-28 18:24:40 +00:00
|
|
|
ax.set_xlabel("Slowdown factor (WebAssembly:Native)")
|
|
|
|
ax.set_title("Python benchmarks")
|
|
|
|
ax.axvline(1.0, color="red")
|
|
|
|
ax.grid(axis="x")
|
|
|
|
ax.legend(loc="lower right")
|
2018-04-05 22:07:33 +00:00
|
|
|
|
|
|
|
plt.savefig(sys.argv[-1])
|