The profiling session is used to store long-term information about the profiled call, including generating the complete callgraph based on cProfile’s stats output.
Of special interest is the uuid that it generates to uniquely track this request.
Given an instance of pstats.Pstats, this will use the generated call data to create a graph using the networkx library. Node and edge information is stored in the graph itself, so that the stats object itself–which can’t be pickled–does not need to be kept around.
Returns a networkx.DiGraph containing the callgraph.
Draws a networkx graph to disk using the dot format.