SnakeViz

2.2.2 · active · verified Thu Apr 09

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.

Warnings

Install

Imports

Quickstart

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.

# 1. Profile your Python script using cProfile
import cProfile
import time

def waste_time():
    sum(range(1000000))

def main():
    for _ in range(5):
        waste_time()

cProfile.runctx('main()', globals(), locals(), 'output.prof')

# 2. Open the profile in SnakeViz from your terminal
#    (Run this in your shell, not in Python directly)
# !snakeviz output.prof

view raw JSON →