import cProfile, pstats, StringIO, introspect from introspect import whatsin s = StringIO.StringIO() pr = cProfile.Profile() pr.enable() whatsin(introspect); pr.disable() ps = pstats.Stats(pr, stream=s).sort_stats('calls') ps.print_stats() print s.getvalue()
#!/usr/bin/env python import sys from pycallgraph import PyCallGraph from pycallgraph.output import GraphvizOutput from introspect import whatsin graphviz = GraphvizOutput(output_file='callgraph.png') with PyCallGraph(output=graphviz): whatsin(sys.argv[4])