>
The standard Python profilers profile and cProfile show you a big list of functions, ordered by the time spent in each function. This is great, but it can be difficult to interpret why those functions are getting called. It's more helpful to know why those functions are called, and which parts of user code were involved.<p>Note that you can use something like gprof2dot to convert pstats dump from cProfile to a visual callgraph: <a href="https://github.com/jrfonseca/gprof2dot#python-cprofile-formerly-known-as-lsprof" rel="nofollow">https://github.com/jrfonseca/gprof2dot#python-cprofile-forme...</a><p>Not saying that solution’s better than pyinstrument — I haven’t use this one before so I’ll have to evaluate. Also, the lower overhead is undeniable.<p>---<p>Edit: Another thing I noticed in "How is it different to profile or cProfile?":<p>> 'Wall-clock' time (not CPU time)<p>> Pyinstrument records duration using 'wall-clock' time. ...<p>Seems misleading as cProfile uses time.perf_counter unless you supply your own timer, and time.perf_counter does measure wall clock time. See<p><a href="https://github.com/python/cpython/blob/ec42789e6e14f6b6ac13569aeadc13798d7173a8/Modules/_lsprof.c#L106-L115" rel="nofollow">https://github.com/python/cpython/blob/ec42789e6e14f6b6ac135...</a><p><a href="https://docs.python.org/3/library/time.html#time.perf_counter" rel="nofollow">https://docs.python.org/3/library/time.html#time.perf_counte...</a>