Skip to content

Commit ef1a603

Browse files
committed
Added legend to performance plots.
1 parent 3b882be commit ef1a603

File tree

2 files changed

+37
-21
lines changed

2 files changed

+37
-21
lines changed

scripts/collect_stats.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ def _parse_cmd_line():
1616

1717

1818
def _main(cmdline):
19+
if not os.path.isdir(cmdline.input):
20+
print("ERROR: The input path is not an existing directory.")
21+
return
1922
result = {}
2023
for root, _, file_names in os.walk(cmdline.input):
2124
is_other = False
@@ -43,6 +46,7 @@ def _main(cmdline):
4346
for _, time in stats["table-phases"].items():
4447
total_time += time
4548
result[os.path.basename(xroot)] = {
49+
"category": "small" if num_locations < 10000 else "big",
4650
"num_goto_program_locations": num_locations,
4751
"time_in_seconds": total_time,
4852
"memory_in_mega_bytes": 0,

scripts/make_performance_scatter_plots.py

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ def choose_colour(colour_index=0):
5151
def make_scatter_plot(
5252
pathname,
5353
format,
54-
points,
54+
point_groups,
5555
title=None,
5656
xaxis_name=None,
5757
faxis_name=None,
5858
xaxis_log=False,
5959
faxis_log=False,
6060
draw_diagonal=False,
6161
draw_fitline=False,
62+
add_legend=False,
6263
size_xy=None,
6364
dpi=None
6465
):
@@ -84,23 +85,31 @@ def make_scatter_plot(
8485
if faxis_log:
8586
ax.set_yscale('symlog')
8687
ax.grid(True, linestyle='dotted')
87-
xs = []
88-
ys = []
89-
for x, y in points:
90-
xs.append(x)
91-
ys.append(y)
92-
ax.scatter(xs, ys)
88+
all_xs = []
89+
all_ys = []
90+
idx = 0
91+
for group, points in point_groups.items():
92+
colour, idx = choose_colour(idx)
93+
xs = []
94+
ys = []
95+
for x, y in points:
96+
xs.append(x)
97+
ys.append(y)
98+
ax.scatter(xs, ys, color=colour, label=group + " (#" + str(len(xs)) + ")")
99+
all_xs += xs
100+
all_ys += ys
101+
ax.legend()
93102
if draw_diagonal:
94103
line = mlines.Line2D([0, 1], [0, 1], color=("blue" if draw_fitline else "red"))
95104
line.set_transform(ax.transAxes)
96105
ax.add_line(line)
97106
if draw_fitline:
98-
line_coefs = numpy.polyfit(xs, ys, 1)
99-
x_lo = min(xs)
100-
x_hi = max(xs)
107+
line_coefs = numpy.polyfit(all_xs, all_ys, 1)
108+
x_lo = min(all_xs)
109+
x_hi = max(all_xs)
101110
n_steps = 1000
102111
dx = (x_hi - x_lo) / n_steps
103-
lxs = sorted(xs + [x_lo + t * dx for t in range(n_steps + 1)])
112+
lxs = sorted(all_xs + [x_lo + t * dx for t in range(n_steps + 1)])
104113
lys = [line_coefs[0] * x + line_coefs[1] for x in lxs]
105114
ax.plot(lxs, lys, "r-")
106115
fig.savefig(pathname, bbox_inches='tight', format=format)
@@ -110,11 +119,16 @@ def _main(cmdline):
110119
with open(cmdline.input, "r") as ifile:
111120
stats = json.load(ifile)
112121

113-
time_points = []
114-
memory_points = []
122+
time_points = {}
123+
memory_points = {}
115124
for _, data in stats.items():
116-
time_points.append((data["num_goto_program_locations"], data["time_in_seconds"]))
117-
memory_points.append((data["num_goto_program_locations"], data["memory_in_mega_bytes"]))
125+
category = "" if "category" not in data else data["category"]
126+
if category not in time_points:
127+
time_points[category] = []
128+
time_points[category].append((data["num_goto_program_locations"], data["time_in_seconds"]))
129+
if category not in memory_points:
130+
memory_points[category] = []
131+
memory_points[category].append((data["num_goto_program_locations"], data["memory_in_mega_bytes"]))
118132

119133
fname_prefix = "security-analyser_stage1_"
120134

@@ -125,9 +139,8 @@ def _main(cmdline):
125139
"Time performance of Stage 1 of the security-analyser",
126140
"goto-program locations",
127141
"seconds",
128-
True,
129-
True,
130-
True
142+
draw_fitline=True,
143+
add_legend=True
131144
)
132145
make_scatter_plot(
133146
os.path.join(cmdline.output, fname_prefix + "memory_perf." + cmdline.format),
@@ -136,9 +149,8 @@ def _main(cmdline):
136149
"Memory performance of Stage 1 of the security-analyser",
137150
"goto-program locations",
138151
"MB",
139-
True,
140-
True,
141-
True
152+
draw_fitline=True,
153+
add_legend=True
142154
)
143155

144156

0 commit comments

Comments
 (0)