Profiler showing path dependency?

Go Luhng goluhng at gmail.com
Fri Mar 13 18:51:10 EDT 2020


Consider a simple call graph: `main()` calls `foo()`, which calls
`bar()`. Then `main()` calls `qux()` which also calls `bar()`, but
with different parameters.

When you run the above through cProfile and view the result in
SnakeViz, you will see `main()` calling `foo()` and `qux()`, with each
of them calling `bar()`. However, if you hover or click on `bar()`,
you will see the global aggregate statistics for it. For example, the
number of times it has been called, and their total time cost.

Is there a way to get a path-dependent profiler breakdown for `bar()`?
 Specifically for this example, statistics for when it is called by
`foo()`, and separately statistics for when it is called by `qux()`.


More information about the Python-list mailing list