191
191
],
192
192
}
193
193
194
+ COLOR_ORDER = ["jit" , "kernel" , "libc" , "library" ] + list (CATEGORIES .keys ())
195
+
196
+
197
+ def get_color_and_hatch (category : str ) -> tuple [str , str ]:
198
+ hatches = ["" , "//" , "\\ \\ " ]
199
+ try :
200
+ index = COLOR_ORDER .index (category )
201
+ except ValueError :
202
+ return "#ddd" , ""
203
+
204
+ return f"C{ index % 10 } " , hatches [index // 10 ]
205
+
194
206
195
207
@functools .cache
196
208
def category_for_obj_sym (obj : str , sym : str ) -> str :
@@ -227,6 +239,9 @@ def _main(input_dir: Path, output_prefix: Path):
227
239
for csv_path in sorted (input_dir .glob ("*.csv" )):
228
240
stem = csv_path .stem .split ("." , 1 )[0 ]
229
241
242
+ if stem .startswith ("sqlalchemy" ):
243
+ continue
244
+
230
245
md .write (f"\n ## { stem } \n \n " )
231
246
md .write ("| percentage | object | symbol | category |\n " )
232
247
md .write ("| ---: | :--- | :--- | :--- |\n " )
@@ -242,6 +257,8 @@ def _main(input_dir: Path, output_prefix: Path):
242
257
for row in csvreader :
243
258
self_time , _ , obj , sym = row
244
259
self_time = float (self_time )
260
+ if self_time > 100.0 :
261
+ print (f"{ stem } Invalid data" )
245
262
if obj == "[JIT]" :
246
263
jit_time += self_time
247
264
else :
@@ -295,21 +312,21 @@ def _main(input_dir: Path, output_prefix: Path):
295
312
bottom = np .zeros (len (results ))
296
313
names = list (results .keys ())[::- 1 ]
297
314
298
- hatches = ["" , "//" , "\\ \\ " ]
299
315
for i , (val , category ) in enumerate (sorted_categories ):
300
316
if category == "unknown" :
301
317
continue
302
318
values = np .array (
303
319
[results [name ].get (category , 0.0 ) for name in names ], np .float64
304
320
)
321
+ color , hatch = get_color_and_hatch (category )
305
322
ax .barh (
306
323
names ,
307
324
values ,
308
325
0.5 ,
309
326
label = f"{ category } { val :.2%} " ,
310
327
left = bottom ,
311
- hatch = hatches [ i // 10 ] ,
312
- color = f"C { i % 10 } " ,
328
+ hatch = hatch ,
329
+ color = color ,
313
330
)
314
331
bottom += values
315
332
@@ -327,8 +344,8 @@ def _main(input_dir: Path, output_prefix: Path):
327
344
labels = [
328
345
i < 10 and f"{ x [1 ]} { x [0 ]:.2%} " or "" for i , x in enumerate (sorted_categories )
329
346
]
330
- colors = [f"C { i % 10 } " for i in range ( len ( values )) ]
331
- hatches = [hatches [ i // 10 ] for i in range ( len ( values )) ]
347
+ colors = [get_color_and_hatch ( cat [ 1 ])[ 0 ] for cat in sorted_categories ]
348
+ hatches = [get_color_and_hatch ( cat [ 1 ])[ 1 ] for cat in sorted_categories ]
332
349
333
350
if sum (values ) < 1.0 :
334
351
other = 1.0 - sum (values )
0 commit comments