VizTracer

1.1.1 · active · verified Sun Apr 12

VizTracer is a low-overhead logging, debugging, and profiling tool for Python that traces and visualizes code execution on a timeline. It supports multi-threading, multi-processing, asyncio, and PyTorch, and the front-end UI is powered by Perfetto. The current version is 1.1.1, and it has a regular release cadence with recent releases approximately every 1-2 months.

Warnings

Install

Imports

Quickstart

This example demonstrates inline usage of VizTracer as a context manager to profile a Python function. After execution, a 'result.json' file is generated, which can be opened and visualized with the `vizviewer` command-line tool.

from viztracer import VizTracer

def my_function():
    total = 0
    for i in range(1000):
        total += i
    return total

with VizTracer(output_file="result.json") as tracer:
    my_function()

# To view the report, run in your terminal:
# vizviewer result.json

view raw JSON →