Examples and workflows#
The repository includes small scripts for specific profiling tasks and a repeatable AI optimization workflow.
Profiling examples#
ex_cli_profiling.py— profile an unmodified script with the CLI.ex_line_profiling.py— collect line-by-line timings.ex_recursive_profiling.py— profile nested calls.ex_region_source.py— retain and inspect region source code.ex_aggregation.py— record compact per-region aggregate statistics without storing an event timeline.benchmark_overhead.py— measure instrumentation overhead.
Run an example with:
python examples/<script>.py
For large or high-frequency workloads, aggregation mode stores call counts, inclusive totals, minimums, maximums, and exclusive totals while keeping the profile small:
with ProfileManager.session(
aggregation_mode=True,
return_results=True,
) as run:
with ProfileManager.profile_region("solve"):
solve()
run.results.print_summary(title="Aggregate profile")
See
ex_aggregation.py
for a complete runnable example. Individual events and timeline plots
are not available in this mode.
AI optimization workflow#
The agent workflow
example
demonstrates measure → edit → re-measure → correctness-check using the
CLI or MCP tools. The runnable repository workload is configured in
benchmarks/sensor.toml.
See
AGENTS.md
for the instructions used by Codex and other coding agents.