summaryrefslogtreecommitdiff
path: root/packages/perf-flamegraph.nix
blob: 92eb326cece48ed1bbf4aefb2e8b9b963bb9c8a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Script that collects perf timing for the execution of a command and
# writes a flamegraph to stdout

{
  writeShellScriptBin,
  perf,
  flamegraph,
  ...
}:

writeShellScriptBin "perf-flamegraph" ''
  set -euo pipefail

  ${perf}/bin/perf record -g --call-graph dwarf -F max "$@"
  ${perf}/bin/perf script \
    | ${flamegraph}/bin/stackcollapse-perf.pl \
    | ${flamegraph}/bin/flamegraph.pl
''