3838 "_Py_GetBaseOpcode" ,
3939 "_PyCode_.+" ,
4040 "_PyEval.+" ,
41- "_PyFrame_ClearExceptCode" ,
42- "_PyFrame_New_NoTrack" ,
43- "_PyFrame_Traverse" ,
41+ "_PyFrame_.+" ,
4442 "_PyPegen_.+" ,
4543 "_PyStack_.+" ,
4644 "_PyVectorcall_.+" ,
7977 "deduce_unreachable" ,
8078 "gc_collect.*" ,
8179 "mark_heap_visitor" ,
80+ "mark_stacks" ,
8281 "PyObject_IS_GC" ,
8382 "scan_heap.+" ,
8483 "type_is_gc" ,
@@ -367,19 +366,22 @@ def plot_bargraph(
367366
368367 bottom = np .zeros (len (results ))
369368 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 )
370371
371372 for val , category in categories :
372373 if category == "unknown" :
373374 continue
374375 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 ,
376378 )
377379 color , hatch = get_color_and_hatch (category )
378380 ax .barh (
379381 names ,
380382 values ,
381383 0.5 ,
382- label = f"{ category } { val :.2%} " ,
384+ label = f"{ category } { val / den :.2%} " ,
383385 left = bottom ,
384386 hatch = hatch ,
385387 color = color ,
@@ -399,7 +401,10 @@ def plot_bargraph(
399401def plot_pie (categories : list [tuple [float , str ]], output_filename : PathLike ):
400402 fig , ax = plt .subplots (figsize = (5 , 3 ), layout = "constrained" )
401403 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+ ]
403408 colors = [get_color_and_hatch (cat [1 ])[0 ] for cat in categories ]
404409 hatches = [get_color_and_hatch (cat [1 ])[1 ] for cat in categories ]
405410
0 commit comments