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.
Getting started — configure the profiler, mark regions, finalize, and inspect the first output file.
Post-processing profiling data — use
ProfilingResults, summaries, DataFrames, filtering, metadata, and JSON.Visualizing results — create Gantt, flame, duration, and speedup charts.
Profiling modes and configuration — recursive, line-by-line, CLI, MPI, and LIKWID profiling.
Custom analysis with the Python API — inspect individual calls, timelines, call stacks, and self-time.
Building your own plots — draw custom visualizations from events and call-stack data.
Notebook magics — profile a cell with
%%scope,%%scope_lineand%%scope_recursive, then compare, analyse and export runs with%scope_compare,%scope_df,%scope_loadand%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 withuse_line_profiler=True.ex_recursive_profiling.py— profiles nested function calls from one decorated entrypoint usingrecursive_profile=True.ex_cli_profiling.py— an uninstrumented script, profiled withscope-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 viascope-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