Interactive Jupyter tutorials

Interactive Jupyter tutorials#

These notebooks are the fastest way to learn scope-profiler. They are listed individually in the documentation navigation so you can jump directly to the topic you need.

Choose a tutorial#

Seven notebooks that build on each other. Each one is self-contained — it generates its own profiling data in a temporary directory, so they can be run in any order and in any environment.

  1. Getting started — configure the profiler, mark regions, finalize, and inspect the first output file.

  2. Post-processing profiling data — use ProfilingResults, summaries, DataFrames, filtering, metadata, and JSON.

  3. Visualizing results — create Gantt, flame, duration, and speedup charts.

  4. Profiling modes and configuration — recursive, line-by-line, CLI, MPI, and LIKWID profiling.

  5. Custom analysis with the Python API — inspect individual calls, timelines, call stacks, and self-time.

  6. Building your own plots — draw custom visualizations from events and call-stack data.

  7. Notebook magics — profile a cell with %%scope, %%scope_line and %%scope_recursive, then compare, analyse and export runs with %scope_compare, %scope_df, %scope_load and %scope_export.

Notebooks 3, 4 and 6 need the post-processing extra, and notebook 7 needs the notebook extra:

pip install "scope-profiler[pproc]"
pip install "scope-profiler[notebook]"

Example scripts#

The examples/ directory in the repository contains ready-to-run scripts:

  • ex_line_profiling.py — demonstrates line-by-line profiling with use_line_profiler=True.

  • ex_recursive_profiling.py — profiles nested function calls from one decorated entrypoint using recursive_profile=True.

  • ex_cli_profiling.py — an uninstrumented script, profiled with scope-profiler run (no decorators or setup calls needed).

  • ex_region_source.py — reads back the source code a region was defined with, both from Python and via scope-profiler inspect --source.

  • benchmark_overhead.py — measures per-call overhead of every profiling mode and produces a bar chart.

Run any example with:

python examples/<script>.py