
Contents
More
Graph structure to represent a profiling.
filename – filename
line – line number
func_name – function name
nc1 – number of calls 1
nc2 – number of calls 2
tin – time spent in the function
tout – time spent in the function and in the sub functions
Profiles the execution of a function.
fct – function to profile
sort – seesort_stats
rootrem – root to remove in filenames
as_df – return the results as a dataframe and not text
return_results – if True, return results as well(in the first position)
kwargs – additional parameters used to create the profiler,seecProfile.Profile
raw results, statistics text dump (or dataframe isas_df is True)
(Sourcecode,png,hires.png,pdf)

Converts profiling statistics into a graphs.
ps – an instance ofpstats
clean_text – function to clean function names
verbose – verbosity
fLOG – logging function
an instance of class @see cl ProfileNode
pyinstrument has a nice display to showtime spent and call stack at the same time. This functiontries to replicate that display based on the results producedby modulecProfile. Here is an example.
<<<
importtimefromonnx_array_api.profilingimportprofile,profile2graphdeffct0(t):time.sleep(t)deffct1(t):time.sleep(t)deffct2():fct1(0.1)fct1(0.01)deffct3():fct0(0.2)fct1(0.5)deffct4():fct2()fct3()ps=profile(fct4)[0]root,nodes=profile2graph(ps,clean_text=lambdax:x.split("/")[-1])text=root.to_text()print(text)
>>>
fct1--33--0.000030.61083--:11:fct1(fct1)<built-inmethodtime.sleep>--33--0.610800.61080--~:0:<built-inmethodtime.sleep>(<built-inmethodtime.sleep>)+++fct4--11--0.000020.81135--:25:fct4(fct4)fct2--11--0.000010.11071--:15:fct2(fct2)fct1--22--0.000020.11070--:11:fct1(fct1)+++fct3--11--0.000010.70062--:20:fct3(fct3)fct0--11--0.000010.20048--:7:fct0(fct0)<built-inmethodtime.sleep>--11--0.200470.20047--~:0:<built-inmethodtime.sleep>(<built-inmethodtime.sleep>)+++fct1--11--0.000010.50013--:11:fct1(fct1)+++<built-inmethodtime.sleep>--44--0.811270.81127--~:0:<built-inmethodtime.sleep>(<built-inmethodtime.sleep>)