Install python-flamegraph into your project:
pip install git+https://github.com/evanhempel/python-flamegraph.git
Record a profile around a bit of code:
import flamegraph
thread = flamegraph.start_profile_thread(fd=open("./profile.log", "w"))
try:
some_code_to_measure()
finally:
thread.stop()
Clone the flamegraph SVG generator somewhere:
git clone [email protected]:brendangregg/FlameGraph.git
Generate the SVG:
./flamegraph.pl profile.log > profile.svg
Optionally, checkout the decorator code below