ac-bench
How-to guides

How-to guide

Profile one case

Re-run a single case under V8's sampling profiler and open its CPU profile in Chrome DevTools or VS Code.

Before you start. A suite that runs with measure -c bench.config.ts, in Node.

1. Find the case’s key

A case’s key is its condition titles and its name, joined with >, as the table prints them. --list prints them without measuring:

Terminal
npx measure -c bench.config.ts --list

2. Profile it

--profile re-runs that one case alone, in a child that profiles it with V8’s sampling profiler, and attaches the profile to the run. The run-json reporter keeps attachments:

Terminal
npx measure -c bench.config.ts --profile "sum 1 000 numbers > reduce" --reporter run-json

The profiler perturbs what it observes, so nothing is measured or gated in that run. The profile covers the fork unit — its hooks and the case — not the process’s start or the TypeScript loader.

3. Save the profile as a file

bench-results.run.json holds it as an attachment of media type application/vnd.v8.cpuprofile+json. Write it out:

Terminal
node -e 'const run = require("./bench-results.run.json"); for (const a of run.attachments) if (a.mediaType === "application/vnd.v8.cpuprofile+json") require("node:fs").writeFileSync("case.cpuprofile", a.body, a.encoding)'

4. Open it

  • Chrome DevTools: the Performance panel, Load profile…, then case.cpuprofile.
  • VS Code: open case.cpuprofile; the built-in viewer shows it as a table and a flame chart.

Variations

Another output name

--output names the file: --output profile writes profile.run.json.