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.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc4585e70877fc7e62597aa1b21e1ed393c38103d80b86f8d482730672924185 |
|
MD5 | 9da4d072cdcc305d75e4888b15c9e9b9 |
|
BLAKE2b-256 | c9ff74eb53854a36caef2098e4682227333803b13aa573d8bdabc704cde8df82 |
Hashes for pyinferno-0.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c0cf2d4d2f583b74c54b877bd5eecb04bfc32908bb8d8892e98a40b7d65598e |
|
MD5 | 2f1ec63eded47b4fc0af48fdbb411f36 |
|
BLAKE2b-256 | 004db00a8bd79ad7d72af9b92593f6fcafe5da20db553552fdb305f0cd547269 |
Hashes for pyinferno-0.2.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f05de4e0534aa44f8f54856891f2e00b5c00b30604615856ff04f6dfac537c44 |
|
MD5 | d6c4db903e0033822a958646ec1bf3bf |
|
BLAKE2b-256 | 467ba98b6035c5a43cc64a18f70d1b109ee36b666219c072a996069d002af39f |
Hashes for pyinferno-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff19e260fea4275dd3c653e4b60d3f8f414a5173c3cbbf684bfab1bc713bb421 |
|
MD5 | dc2822a195c4e1ac39611dad23a52e5c |
|
BLAKE2b-256 | 12fcc977f4831c20927b5b80e0d041732144db12c12a9fd7468d207c176b0ea0 |
Hashes for pyinferno-0.2.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84c42c99faf93dad44bd3ce66ecdcc6cd1d9f4d8272bf94194e5e56116ba6091 |
|
MD5 | 71d4904d825b7c21fd030c98b278eb62 |
|
BLAKE2b-256 | aa5be5147a1546c6041b6350af25561d2e695ea49bce402b5185ec2d8b62d7f4 |
Hashes for pyinferno-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86fc1605593568a07a89753c03d84fd47c17057cd72e750f191d7ee9290d582a |
|
MD5 | e7a1e44138a0446097de717ce1af77fb |
|
BLAKE2b-256 | bb5a854be3ef2d29932dc4705554df89e0d69d6883c0ee9a01f82d9ee36113ec |
Hashes for pyinferno-0.2.0-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0337564699e19aeb0ce5a95814a1abb732cf21d38c9c0546a74601b8522e3c7 |
|
MD5 | d232a1a1824988a1a7d0bd3da3dd6c6a |
|
BLAKE2b-256 | 6d43a1dddc9068fc5a9e9b752a7cdeeda9d7dbf2a8bcd910f348b60813c36cdc |
Hashes for pyinferno-0.2.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fa71582c16f4c887d15b2acdd5fd60976dce644001b56d4085f3c180c96757e |
|
MD5 | abd287b3fc2602a377dfef3702a9c9fa |
|
BLAKE2b-256 | 639508877160bee8a393724a1be8d06ae7822b1c2fb395235a8192b55b071868 |
Hashes for pyinferno-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f6a513bc55e58e781d3354144a01ad3c920616946fc5f44141b4d53ea181779 |
|
MD5 | ad2826c20d6d4ce33107072947748479 |
|
BLAKE2b-256 | f56fe992d7e785574493ab7149fe6dc1509715c66ce2c7abb05770ccc104eca0 |
Hashes for pyinferno-0.2.0-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dd0be5d093d4ec0d1302a4451c2eeff185da8a6ce6c63c4ca9a8473e207fe48 |
|
MD5 | 3e8641c4cd77d0c32dfefa17e10b53ec |
|
BLAKE2b-256 | 56730e1badc5d7ba8d5cc349778433263a9d37033133af462d63c63c4530e510 |
Hashes for pyinferno-0.2.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 080fa8bd39aa04c9fc5adb2c8670d32ba3c9357e2bd3f45bae99b19b6f2ab52c |
|
MD5 | 74d1206555f2cb3aedc4e5a5b66562f6 |
|
BLAKE2b-256 | fe67926a9590d84a5d447d641072a9894613a1f83196031006deafff1ca6043f |
Hashes for pyinferno-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5a9dc7dca5321f0ccaee291619ede3195ac74c060fa02c1d8ed3067f3d6cf04 |
|
MD5 | 9d4c3be3c1b76d4b2cfcd1742915f94b |
|
BLAKE2b-256 | d75361b587edfaf20d3b0329e43fb30b10875378b9b1c26e680480eed809dbe1 |
Hashes for pyinferno-0.2.0-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ad4263bfd6822d3d4210131d017084ed367627f82d0bb8c4f09aa93577b7a08 |
|
MD5 | 4fa60f2b05929c18dd9f2bd65a24fc7b |
|
BLAKE2b-256 | fb103672339a166b7b459547f35e4779ca651a5341d6d3bd2c435016a8f7015f |
Hashes for pyinferno-0.2.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccb277368b82e185658f7346f75fd2fcd25c6794c60c0054bc0c91bac947c050 |
|
MD5 | 3fc9ace1ac44b0af2b4709893c783ead |
|
BLAKE2b-256 | 75b404103587b763fadc60942537089e280bf58d5cdde277d10ce13983653991 |
Hashes for pyinferno-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 704f8c618b370f3d67c75a837435b35baf18ba61aa69df3b4e074df1e55f40c3 |
|
MD5 | bee77d005b920124aac4ed0256fbe9cc |
|
BLAKE2b-256 | 1fb90587fa7eece9b3e227e5eba4200babc9f50bf293291f65d23a112f09aaff |
Hashes for pyinferno-0.2.0-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | def14847fb19ac2225666572ebba6be2f293b579c40a3ff7ff3310894009cc16 |
|
MD5 | 5f1dc8dcf11fc8a9f87b720439c86170 |
|
BLAKE2b-256 | cab27ba4c236bed1ba4d650c0aa5c1a777ec23e502118c4459f8e8d15ce182f5 |