Simple python flame graph generator
Project description
PyInferno
Python package that renders pyinstrument profiles as flamegraphs, using the inferno rust crate.
Installation
Install from PyPi:
pip install pyinferno
Usage
Context manager
To profile a specific piece of code, you can use the pyinstrument Profiler class, then render the result using pyinferno's InfernoRenderer
:
from pyinstrument.profiler import Profiler
from pyinferno import InfernoRenderer
import time
def slow():
time.sleep(0.5)
with Profiler() as profiler:
slow()
output = profiler.output(InfernoRenderer(title="slow"))
with open("flamegraph.svg", "w+") as f:
f.write(output)
For convenience, the same result can be achieved using the InfernoProfiler
context manager:
from pyinferno import InfernoProfiler
import time
def slow():
time.sleep(0.5)
with InfernoProfiler(file="flamegraph.svg", auto_open=True, title="slow"):
slow()
Command-line
To profile a Python script, you can pass pyinferno.Renderer
as the renderer to the pyinstrument
CLI:
pyinstrument -r pyinferno.Renderer -o flamegraph.svg slow.py
For convenience, pyinferno
includes its own script which wraps the pyinstrument
CLI:
pyinferno slow.py
If no output file is specified, the flamegraph will be written to a temporary file and automatically opened using python's webbrowser
module. To save the flamegraph to a file, pass the -o
option:
pyinferno -o flamegraph.svg slow.py
To profile a python module, pass the -m
argument:
pyinferno -m pytest -k slow_test
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pyinferno-0.2.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5e1af93d51ba254944f119881dd601518564d5688f339d21d769243687f56cc |
|
MD5 | cd49f7fe65028d5992f1de31bcf8a1d2 |
|
BLAKE2b-256 | dbc62ed38ceee42b28df929360ab0cfe44c06028ef03529afbb26319a4342e3e |
Hashes for pyinferno-0.2.6-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a51faf7b317796594cd102f2b391ee02ed7ffa82d2466806df7cf9b929e7af26 |
|
MD5 | 994382fed8f9e1e4572c942c76c4cef3 |
|
BLAKE2b-256 | 30ba72a25e34361414e31ea426bf2cedb2627efa30fc96998ab01ad3fa283b71 |
Hashes for pyinferno-0.2.6-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72b0c0d33f9788d770ebc4791c7594effbbbb1c0ce8c1c2185f0902a466c70d8 |
|
MD5 | 718c72472c738ad270788ea0e3af7687 |
|
BLAKE2b-256 | 5de713fa0e97684a3895f18a77686db6de27a00be86580104397802be2305cb6 |
Hashes for pyinferno-0.2.6-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0eda3ca7afff448a81d1836456344360c41400c539b994b8201982ae913af4a0 |
|
MD5 | 6c544d3e7be2f3d81b2a47b888c85e31 |
|
BLAKE2b-256 | bb12d0979ca9c294fb47cb0b5c9f52cf73392957e3cd834e6437730eef0be830 |
Hashes for pyinferno-0.2.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4890317a77e88ca26487551211cc519b23f239e93b008425b82a5961b7afe21a |
|
MD5 | d4fe58789b0c0ec6219bcd4098c2809a |
|
BLAKE2b-256 | b44df912f892f88382ac9233cb3cea83df12a96f41a5c39a16d673fc77ca184c |
Hashes for pyinferno-0.2.6-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05f52b2afb50d8b8f771faa81e6daadd83599fc853a1c36916f9c3013b6fc077 |
|
MD5 | 515d2e0eadbbb58a029a225071e57b34 |
|
BLAKE2b-256 | d00d7b4d937cfbf58b436a9eb64e361267fc9fb4265a2db1c69321a2517c4f3e |
Hashes for pyinferno-0.2.6-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0ceb8c3f6a6254338f40705fb6d462dffc165d5e77159d5420ee31d2d8d08fc |
|
MD5 | 447b8602328bb9db547147ae5c4292f5 |
|
BLAKE2b-256 | f62b75ec49c817e61e23276febde9fcc9e918fb854e6f9e27d411ebd4ce7ad96 |
Hashes for pyinferno-0.2.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccf9f4f466188c36625bd46884f1d857a7bf27d8e35aa46f914adeaaf5065704 |
|
MD5 | 186cc12c119f426a4b64d1c3919eacf3 |
|
BLAKE2b-256 | 6cc67a319bdda223a52455232b97891749482d94cb436cc9a0dc6d5c75eeb2d8 |
Hashes for pyinferno-0.2.6-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb13c315431bc6b535dd6e68abf772770085b6d79f0f77a3a3cda55dac647264 |
|
MD5 | 86f6c603cd1c1d18cce0f367617f09e1 |
|
BLAKE2b-256 | 0999125eb752ca9e93ba976b3fe2a27487da7bb5ca1beceaa5a99f2169a37628 |
Hashes for pyinferno-0.2.6-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36168246c7fcc4aca59cc463bc454968ce75d4f027e974f25c4c4814423003ff |
|
MD5 | 533816b2301a1c87a8d7e3a7c681383d |
|
BLAKE2b-256 | 99326e78b079773dced81797b257539972e64682a6ed95d64d14aecb56f97190 |
Hashes for pyinferno-0.2.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e304f7b78924d3e5a98fc2966e285b7e5b10d0f0e6450fb201ad77e8b13d8f5 |
|
MD5 | 4d057c5738f011eeb45fc2f45a89f308 |
|
BLAKE2b-256 | e99386c0883981055167f9cec80c0fbbe74b4f1c3e98b3ac8b0bdc91ec51495f |
Hashes for pyinferno-0.2.6-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad03786fb06caf3ba8c3f48b98f0d13988a69f639e34f9deaea9f9e3c873181b |
|
MD5 | e758ceba7ccc15af053693963a8287e8 |
|
BLAKE2b-256 | e19f2d8609828eb1eefc56757b6ab2abee23b3b33afd70365a1c190842ee1275 |
Hashes for pyinferno-0.2.6-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cac475260d60b1568ff4b1e0cc40f1c32c33ff4324651c9db134f21fca5a0e3c |
|
MD5 | 92a9d8afe6926b700181c972fc6f27c0 |
|
BLAKE2b-256 | a679e54806c7700ff332899c05bb52823f60b6ce94dee774f2995ae0d41b73bf |
Hashes for pyinferno-0.2.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33f481bae866bf41faa2444016ad7ceb76498db0674d644ee4e6435bd15c31c3 |
|
MD5 | 544496c3a20eef3ef013af37f15a79bb |
|
BLAKE2b-256 | d2fe7a941072372906ebd94ed15d2977448265374603d145b2c62647fc643bf0 |
Hashes for pyinferno-0.2.6-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffe6f16737ebafe879f35880a87b8a4d63721989208b1077bcf2cb4b95fef75e |
|
MD5 | 4879b0982dd435edaf6eac2a2e0fd604 |
|
BLAKE2b-256 | 9234ab675d935eda57a302780d78dc230a0119e452ea0a812393c888854b463a |
Hashes for pyinferno-0.2.6-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcdbbe7905638b889562a262cdb0d2ae1a6a79b307151636814a97be1ffae29d |
|
MD5 | b2f3de9c480047c077fce703db8756bf |
|
BLAKE2b-256 | 979827e821727fce1902571a32040338cb1e122a5e8c22585a225de6b7dfb4fb |
Hashes for pyinferno-0.2.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b725d8b06e6b54dd3b5689cc7ed3209226f1b5412ccc8eec10b53f508edad6f |
|
MD5 | 6cdde44b96b35effda14263565783129 |
|
BLAKE2b-256 | 5b36a70f0bf74bc9d46a56b399134e5f57bdcd09371cdca3755c0894c252f62b |
Hashes for pyinferno-0.2.6-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d58f9421e29d51ae8e6aa0be191fc55adda9178faa120095e57f2bcd1214001d |
|
MD5 | 7d462d93b538cce8bca09423d35db026 |
|
BLAKE2b-256 | 3777c660b0ebe85a5a74ab1db6df551410b398ee9548132d33cf3e25cce4c6e4 |