-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplot.py
75 lines (68 loc) · 2.41 KB
/
plot.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
# Using `matplotlib`, plot the results of the given benchmark .dat file.
import matplotlib.pyplot as plt
import pandas as pd
import pathlib
import sys
from cycler import cycler
def read_dat(path: str) -> pd.DataFrame:
"""
Read in a table formatted like a .dat file: whitespace is used to separate columns.
"""
dat_file = pathlib.PurePath(path)
with open(dat_file, "r") as dat:
return pd.read_table(dat, delim_whitespace=True)
def plot_modular_vs_mono(
modular_table: pd.DataFrame, mono_table: pd.DataFrame, timeout=None
):
"""
Plot verification time with respect to the number of nodes for modular verification
vs. monolithic verification.
If a `timeout` is given, add as an additional horizontal line.
"""
cute_cycler = cycler(
color=[
"darkseagreen",
"coral",
"goldenrod",
"cornflowerblue",
]
) + cycler(
marker=["p", "^", "s", "D"] # pentagon, triangle, square, diamond
)
fig, ax = plt.subplots()
ax.set_prop_cycle(cute_cycler)
ax.set_xlabel("Number of nodes")
ax.set_yscale("log")
ax.set_ylabel("Verification time (seconds)")
if timeout is not None:
to_line = ax.axhline(y=timeout, linestyle="--", color="#000000")
# annotate that this is the timeout line
ax.annotate(
"SMT timeout",
(0.2, 1),
xycoords=to_line,
ha="center",
va="top",
xytext=(0, -5),
textcoords="offset points",
)
ax.plot("n", "wall", label="Timepiece (wall)", data=modular_table)
ax.plot("n", "99p", label="Timepiece (99th percentile)", data=modular_table)
ax.plot("n", "med", label="Timepiece (median)", data=modular_table)
ax.plot("n", "total", label="Monolithic", data=mono_table)
ax.legend()
ax.grid(True, which="major")
return fig
if __name__ == "__main__":
if len(sys.argv) < 3:
raise Exception(
"Usage: plot.py [modular dat file] [mono dat file] [output file (default: plot.pdf)] [timeout (in seconds)?]"
)
modular_table = read_dat(sys.argv[1])
mono_table = read_dat(sys.argv[2])
plotfile = sys.argv[3] if len(sys.argv) > 3 else "plot.pdf"
timeout = float(sys.argv[4]) if len(sys.argv) > 4 else None
fig = plot_modular_vs_mono(modular_table, mono_table, timeout)
# plt.show()
fig.savefig(plotfile)