Documentation typically recommends that python profilers be run as modules. Integrating them into the code directly as a 1-line import plus decorator makes it a lot easier to teach new developers to use the profilers.
I don't have much experience with python profiling, but this looks like a really easy way to get granular performance metrics. I could see this being quite useful in longer functions with multiple performance sensitive parts. I'll make sure to keep this profiling technique in mind next time I have to write Python.
Line profiling like this is a lot easier for me to interpret than flame graphs, and the decorator seems convenient enough to just stick on any function. How does it work if you want to profile multiple functions within a stack?
4 comments
[ 2.8 ms ] story [ 20.6 ms ] thread