38
38
"_Py_GetBaseOpcode" ,
39
39
"_PyCode_.+" ,
40
40
"_PyEval.+" ,
41
- "_PyFrame_ClearExceptCode" ,
42
- "_PyFrame_New_NoTrack" ,
43
- "_PyFrame_Traverse" ,
41
+ "_PyFrame_.+" ,
44
42
"_PyPegen_.+" ,
45
43
"_PyStack_.+" ,
46
44
"_PyVectorcall_.+" ,
79
77
"deduce_unreachable" ,
80
78
"gc_collect.*" ,
81
79
"mark_heap_visitor" ,
80
+ "mark_stacks" ,
82
81
"PyObject_IS_GC" ,
83
82
"scan_heap.+" ,
84
83
"type_is_gc" ,
@@ -367,19 +366,22 @@ def plot_bargraph(
367
366
368
367
bottom = np .zeros (len (results ))
369
368
names = list (results .keys ())[::- 1 ]
369
+ dens = {key : sum (val .values ()) for key , val in results .items ()}
370
+ den = sum (x [0 ] for x in categories )
370
371
371
372
for val , category in categories :
372
373
if category == "unknown" :
373
374
continue
374
375
values = np .array (
375
- [results [name ].get (category , 0.0 ) for name in names ], np .float64
376
+ [results [name ].get (category , 0.0 ) / dens [name ] for name in names ],
377
+ np .float64 ,
376
378
)
377
379
color , hatch = get_color_and_hatch (category )
378
380
ax .barh (
379
381
names ,
380
382
values ,
381
383
0.5 ,
382
- label = f"{ category } { val :.2%} " ,
384
+ label = f"{ category } { val / den :.2%} " ,
383
385
left = bottom ,
384
386
hatch = hatch ,
385
387
color = color ,
@@ -399,7 +401,10 @@ def plot_bargraph(
399
401
def plot_pie (categories : list [tuple [float , str ]], output_filename : PathLike ):
400
402
fig , ax = plt .subplots (figsize = (5 , 3 ), layout = "constrained" )
401
403
values = [x [0 ] for x in categories ]
402
- labels = [i < 10 and f"{ x [1 ]} { x [0 ]:.2%} " or "" for i , x in enumerate (categories )]
404
+ den = sum (values )
405
+ labels = [
406
+ i < 10 and f"{ x [1 ]} { x [0 ] / den :.2%} " or "" for i , x in enumerate (categories )
407
+ ]
403
408
colors = [get_color_and_hatch (cat [1 ])[0 ] for cat in categories ]
404
409
hatches = [get_color_and_hatch (cat [1 ])[1 ] for cat in categories ]
405
410
0 commit comments