-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
47 lines (32 loc) · 931 Bytes
/
plot.py
File metadata and controls
47 lines (32 loc) · 931 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
"""
Plotting module based on qulacs benchmark
Based on: https://github.com/qulacs/benchmark-qulacs
"""
import json
from collections import defaultdict
import pyperf
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
nqubits_list = range(4, 27)
liblist = ["pennylane", "spinoza"]
def load() -> defaultdict:
res = defaultdict(dict)
for lib in liblist:
suite = pyperf.BenchmarkSuite.load(f"./{lib}/results.json")
for n in nqubits_list:
bench = suite.get_benchmark(f"qcbm {n}")
res[lib][n] = bench.median()
return res
def plot(data: defaultdict) -> None:
for lib in liblist:
x, y = zip(*data[lib].items())
plt.plot(x, y, label=lib)
plt.xlabel("qubits")
plt.ylabel("time")
plt.yscale("log")
plt.legend()
plt.tight_layout()
plt.savefig("images/plot.png", dpi=600)
if __name__ == "__main__":
plot(load())