@@ -24,25 +24,26 @@ def runFlamegraph(ns):
2424
2525def flamegraphCommand (profilingfile , participant , unit = "us" ):
2626 run = Run (profilingfile )
27- df = run .toDataFrame ()
2827
29- assert df .select (
30- pl .col ("participant" ).is_in ([participant ]).any ()
31- ).item (), f"Given participant { participant } doesn't exist."
28+ participants = run .participants ()
29+ assert (
30+ participant in participants
31+ ), f"Given participant { participant } unknown. Known participants are { ', ' .join (participants )} "
3232
33+ df = run .toDataFrame (participant = participant )
3334 print (f"Output timing are in { unit } ." )
3435
3536 def toParent (eid ):
3637 if eid == "_GLOBAL" :
3738 return ""
3839 if "/" not in eid :
3940 return "_GLOBAL"
40- return "/" . join ( eid .split ("/" )[: - 1 ])
41+ return eid .rpartition ("/" )[0 ]
4142
4243 def toLabel (eid ):
4344 if eid == "_GLOBAL" :
4445 return participant
45- return eid .split ("/" )[- 1 ]
46+ return eid .rpartition ("/" )[2 ]
4647
4748 # Filter by participant
4849 # Convert duration to requested unit
@@ -66,6 +67,12 @@ def toLabel(eid):
6667 .sort ("eid" )
6768 )
6869
70+ hovertemplate = (
71+ "<b>%{label}</b><br><i>%{id}</i><br>%{value}"
72+ + unit
73+ + "<br>%{percentParent:.1%} of parent<br>%{percentRoot:.1%} of total"
74+ )
75+
6976 primaryPlot = go .Icicle (
7077 labels = primary ["label" ].to_list (),
7178 ids = primary ["eid" ].to_list (),
@@ -74,7 +81,8 @@ def toLabel(eid):
7481 branchvalues = "total" ,
7582 tiling = dict (orientation = "v" , flip = "y" ),
7683 root_color = "lightgrey" ,
77- hovertemplate = "<b>%{label}</b><br><i>%{id}</i><br>%{value} " + unit ,
84+ hovertemplate = hovertemplate ,
85+ textinfo = "label+percent root" ,
7886 )
7987
8088 if len (df .select ("rank" ).unique ()) == 1 :
@@ -107,7 +115,8 @@ def toLabel(eid):
107115 branchvalues = "total" ,
108116 tiling = dict (orientation = "v" , flip = "y" ),
109117 root_color = "lightgrey" ,
110- hovertemplate = "<b>%{label}</b><br><i>%{id}</i><br>%{value} " + unit ,
118+ hovertemplate = hovertemplate ,
119+ textinfo = "label+percent root" ,
111120 ),
112121 row = 1 ,
113122 col = 2 ,
0 commit comments