@@ -51,14 +51,15 @@ def choose_colour(colour_index=0):
51
51
def make_scatter_plot (
52
52
pathname ,
53
53
format ,
54
- points ,
54
+ point_groups ,
55
55
title = None ,
56
56
xaxis_name = None ,
57
57
faxis_name = None ,
58
58
xaxis_log = False ,
59
59
faxis_log = False ,
60
60
draw_diagonal = False ,
61
61
draw_fitline = False ,
62
+ add_legend = False ,
62
63
size_xy = None ,
63
64
dpi = None
64
65
):
@@ -84,23 +85,31 @@ def make_scatter_plot(
84
85
if faxis_log :
85
86
ax .set_yscale ('symlog' )
86
87
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 ()
93
102
if draw_diagonal :
94
103
line = mlines .Line2D ([0 , 1 ], [0 , 1 ], color = ("blue" if draw_fitline else "red" ))
95
104
line .set_transform (ax .transAxes )
96
105
ax .add_line (line )
97
106
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 )
101
110
n_steps = 1000
102
111
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 )])
104
113
lys = [line_coefs [0 ] * x + line_coefs [1 ] for x in lxs ]
105
114
ax .plot (lxs , lys , "r-" )
106
115
fig .savefig (pathname , bbox_inches = 'tight' , format = format )
@@ -110,11 +119,16 @@ def _main(cmdline):
110
119
with open (cmdline .input , "r" ) as ifile :
111
120
stats = json .load (ifile )
112
121
113
- time_points = []
114
- memory_points = []
122
+ time_points = {}
123
+ memory_points = {}
115
124
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" ]))
118
132
119
133
fname_prefix = "security-analyser_stage1_"
120
134
@@ -125,9 +139,8 @@ def _main(cmdline):
125
139
"Time performance of Stage 1 of the security-analyser" ,
126
140
"goto-program locations" ,
127
141
"seconds" ,
128
- True ,
129
- True ,
130
- True
142
+ draw_fitline = True ,
143
+ add_legend = True
131
144
)
132
145
make_scatter_plot (
133
146
os .path .join (cmdline .output , fname_prefix + "memory_perf." + cmdline .format ),
@@ -136,9 +149,8 @@ def _main(cmdline):
136
149
"Memory performance of Stage 1 of the security-analyser" ,
137
150
"goto-program locations" ,
138
151
"MB" ,
139
- True ,
140
- True ,
141
- True
152
+ draw_fitline = True ,
153
+ add_legend = True
142
154
)
143
155
144
156
0 commit comments