SnakeViz is a web-based viewer for Python profiler output, specifically designed for data generated by the `cProfile` module. It provides interactive graphical visualizations (icicle and sunburst charts) to help identify performance bottlenecks in Python code. The current version is 2.2.2, with releases occurring periodically to add features and address compatibility.
pip install snakevizVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to profile a Python function using the built-in `cProfile` module and then visualize the generated profile data with SnakeViz from the command line. For Jupyter/IPython, use the `%snakeviz` magic after loading the extension.
Always use `cProfile` for generating profile data (e.g., `python -m cProfile -o output.prof my_script.py`).
To mitigate this, try increasing the 'cutoff' value, reducing the 'depth' of the visualization, or profile a smaller, more focused subsection of your code. You can also manually navigate the stats table if the visualization fails.
Be aware of this limitation when interpreting results, particularly with highly recursive or complex call patterns. Focus on the overall time distribution and major bottlenecks rather than micro-analyzing every single call path.
Upgrade your Python environment to 3.9 or newer to ensure compatibility and receive updates. If Python 2.7 is strictly required, pin SnakeViz to a version `<=2.1.2`.
Use the `--new-tab` or `-t` option with `%snakeviz` magic if you prefer to always open in a new tab, even in Jupyter. If working offline, save a profile file and use the command-line interface as IPython magics require internet access.