lean-bench

5. Profiling🔗

Issue #13. Once lake exe bench run flags a regression, the next question is why. lean-bench gives you a way to run a single benchmark invocation under any external profiler — perf, samply, heaptrack, /usr/bin/time -v, valgrind --tool=callgrind, … — without writing shell glue.

The mechanism is intentionally minimal: the profile subcommand re-invokes the benchmark binary in child mode at one parameter, but with your profiler command prefixed in front. The profiler sees a single short-lived child process that runs the registered function many times (under the default cacheMode := .warm autotuner) and then exits. Whatever output the profiler produces — flamegraphs, counters, allocation traces — lands directly on your terminal or in files at the location it chose.

This page documents four end-to-end workflows. None of them require modifying your setup_benchmark declarations. All of them assume you already have a populated benchmark binary; if not, see Quickstart first.

  1. 5.1. How profile works
  2. 5.2. Workflow 1 perf stat
  3. 5.3. Workflow 2 perf record and flamegraphs
  4. 5.4. Workflow 3 samply
  5. 5.5. Workflow 4 time -v and heaptrack
  6. 5.6. Picking the right cache mode
  7. 5.7. What profile does not do
  8. 5.8. Platform notes
  9. 5.9. Acceptance criteria status