Skip to content

Commit 70825b7

Browse files
Document perf profiling tool in compilation-and-development.md
Add a 'Profiling with perf (recommended)' subsection to the existing Time profiling section, describing scripts/profile_cbmc.py with usage examples. The existing gprof documentation is preserved as a separate subsection. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
1 parent 44306e3 commit 70825b7

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

doc/architectural/compilation-and-development.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,42 @@ There are also instructions for adding this as a git pre-commit hook in
281281

282282
\section compilation-and-development-section-time-profiling Time profiling
283283

284+
\subsection compilation-and-development-subsection-perf-profiling Profiling with perf (recommended)
285+
286+
The script `scripts/profile_cbmc.py` profiles CBMC's pre-solver stages using
287+
`perf` and generates interactive flamegraphs. Solver time is excluded by default
288+
so that results reflect only CBMC's own code. This requires Linux with `perf`
289+
installed.
290+
291+
Quick start with built-in benchmarks:
292+
293+
scripts/profile_cbmc.py --auto
294+
295+
For multiple runs (reports mean ± stddev):
296+
297+
scripts/profile_cbmc.py --auto --runs 3
298+
299+
To profile a specific input file:
300+
301+
scripts/profile_cbmc.py test.c -- --bounds-check --unwind 100
302+
303+
For source-level call site resolution, build a separate debug binary and pass it
304+
via `--debug-binary` (profiling still uses the fast Release build):
305+
306+
cmake -S . -Bbuild-debug -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_JBMC=OFF
307+
cmake --build build-debug --target cbmc -j$(nproc)
308+
scripts/profile_cbmc.py --auto --debug-binary build-debug/bin/cbmc
309+
310+
To compare performance between two git refs:
311+
312+
scripts/profile_cbmc.py --diff develop my-optimization-branch
313+
314+
Results are written to `profile-results/` by default and include flamegraph SVGs,
315+
a text summary with hotspot analysis, and machine-readable JSON. Run
316+
`scripts/profile_cbmc.py --help` for the full set of options.
317+
318+
\subsection compilation-and-development-subsection-gprof-profiling Profiling with gprof
319+
284320
To do time profiling with a tool like `gprof`, the flags `-g` (build with debug
285321
symbols) and `-pg` (enable profiling information) must be
286322
used when compiling, and `-pg` must be used when linking. If you are building

0 commit comments

Comments
 (0)