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, 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.render(InfernoRenderer(title="slow"))
with open("flamegraph.svg", "w+") as f:
f.write(output)
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.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 339127b9d18e579f1afeb91ec1c98df317674340bbcf720ea298d216591d8837 |
|
MD5 | e4a6348c5c43caa014c9a1dd1a6f2b53 |
|
BLAKE2b-256 | 2f367250e969893ec43a429a839093eb360ede4ab26181f7589b9cfa04d176e2 |
Hashes for pyinferno-0.2.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 424c720cd3c210e1097dee7f01098afd2e680ac9b5e34c2228a17ff89d8afdf2 |
|
MD5 | 8539aefddf821dc7eff41a1b06103def |
|
BLAKE2b-256 | 81976e493773a17cda85b41439104b7a8571e206f83c1d11480cbb862fbce600 |
Hashes for pyinferno-0.2.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31cb335f4a503c4fcd37130cc15dc21968e98fa53a4839122824a0b8666265ba |
|
MD5 | e8306c8a146224091b3dc83b3a250b53 |
|
BLAKE2b-256 | afb3637f99590312cc4363a549643d7b738cd506374a50fd0fa944ad7bf75279 |
Hashes for pyinferno-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af2439620de1f6d63566de41c8ac644eec65495607841232ba8a4a3eaa0823bb |
|
MD5 | 08c816eea1cf65625613f62ac1b3f60e |
|
BLAKE2b-256 | e41dd6213a1cfccc3e1e2558cfafbd4f29557e7c74cfc0494b90b8cf1825e741 |
Hashes for pyinferno-0.2.1-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 898ba7f58c595d06690e3238a4c8fdca12a9add2cd7a7304414e3a908c4e5d32 |
|
MD5 | 8524c52d94041e506585baefbd723ff7 |
|
BLAKE2b-256 | 07ae8f5ed2950ccb9097078ffa0dbd0395a76a45cb16b0fe4d4110d32e71b66e |
Hashes for pyinferno-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adabad4f1198e6607f834688068481069368f06cb053872bd1433960ad6b3348 |
|
MD5 | 8d86680c15bb5a4945887164a9508205 |
|
BLAKE2b-256 | ceca680e5f7ef85d4244d1d0c40ae0d4fedde8b854a8cc64f43515b9218f73a6 |
Hashes for pyinferno-0.2.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d7d8be7c6f7d46aac39a5a83dcfd009b77e49c47e94f1cbfb7b4ea67c256945 |
|
MD5 | 9e602611473f97873b0828134676150c |
|
BLAKE2b-256 | 9786a268bdcaddd1de02013274f8d21f49598f124294ddd742a93c3cba58d4bf |
Hashes for pyinferno-0.2.1-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28e177898d2863d1e676caa2a7f38875f7e79d6fc00dfde2a9c470c9cf5a2083 |
|
MD5 | 407a2f1993cdfa7992855fcd9326028e |
|
BLAKE2b-256 | 7517abb36cc9608eccd44271e5fbe6510075327be0bea0f1b00c9a0462dc086d |
Hashes for pyinferno-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d817bc4a471746c32531e50108875091dac64e3a792b0a6bdd8b5fc170cec8da |
|
MD5 | b7d1be7916c4b4ccebbaff73ec48ddb1 |
|
BLAKE2b-256 | bf077dd9ace594bd93e3f9a7cb899f8a0191178b7e3d6f2a86880b2c576ba915 |
Hashes for pyinferno-0.2.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32172bc074c683fe93b35439468da2452ccaaf5a326ac4de29262cdd259047cb |
|
MD5 | 26862595584f155e5e9e7474eacfae80 |
|
BLAKE2b-256 | 73c1e932d906630fd414a66ee5e5fbdadcbd74a7afe8076ad35359140ca775c2 |
Hashes for pyinferno-0.2.1-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9c06be03276943b86dcc8cccc7b2723500406dc7d8a7ca41bb0ed4f21278e72 |
|
MD5 | d90e61c79552782a1dae446eae377eda |
|
BLAKE2b-256 | 607fcff464e68ebd0c1a7aad416b62a762779e0b65db3fe8cf6dfdde759acd85 |
Hashes for pyinferno-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e37c5aa18912272006d1d1b3b7c0cc7d458a31d1debc434804f861136bd32d83 |
|
MD5 | e4f520e81e30681661fbf3c244da4036 |
|
BLAKE2b-256 | 39197eb73fe2b16b182ba04f6c4ab459dad26a77ea037697b6a3eb357a5b3f2d |
Hashes for pyinferno-0.2.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27c453bbc90510fe3290058be302f361dfbe0f94d6bbf0ce4b2e7441ca459e97 |
|
MD5 | c796eed5fef2759081022890fc9f00d9 |
|
BLAKE2b-256 | b4dd8c81d78c204b15a38ddb78ca957956313434308710e7060e366f7605304e |
Hashes for pyinferno-0.2.1-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9eb688f59b76df63d1d5b939d9749127845ca1cc67527078f6cdae850e4a672d |
|
MD5 | cb0251a534ff0d572036768b6302cde3 |
|
BLAKE2b-256 | d4eaf599bb32629d93cd42042b0fc76355c2652fc98590999befa5b375bf0c8e |
Hashes for pyinferno-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b337bbf97c6db96e52dded90d9cb6c913b3fc50706461301d17190846c9dbb8 |
|
MD5 | c242e925e8483c2a9084adfbb776c773 |
|
BLAKE2b-256 | 0b2bb3c1ba721b16219ac5f8bb9416b69728a1c135fbc0a004017202ba08eb63 |
Hashes for pyinferno-0.2.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5e8a22d14389058e15b096da27f43101725010a40559c75be83fdfbb68e8026 |
|
MD5 | 7c70f2ae92e9f762103d96c0081d9247 |
|
BLAKE2b-256 | 6229341684d447c443e1e1bdcf0ef12a32cb1dd74420cfc73e706a0db4534107 |