feat(tools): Add script to flamegraph a command
Add tools.perf-flamegraph, which collects the base case execution of perf piped through stackcollapse-perf and flamegraph to flamegraph the execution of an external command via perf. Change-Id: I671fe254dc374b6cd7deca2d3bdea266164de025 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1176 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
3fcebfdaa1
commit
04ae293360
4 changed files with 18 additions and 0 deletions
|
@ -40,6 +40,9 @@ case "${TARGET_TOOL}" in
|
|||
ninja)
|
||||
attr="third_party.ninja"
|
||||
;;
|
||||
perf-flamegraph)
|
||||
attr="tools.perf-flamegraph"
|
||||
;;
|
||||
rebuild-system)
|
||||
attr="ops.nixos.rebuild-system"
|
||||
;;
|
||||
|
|
1
bin/perf-flamegraph
Symbolic link
1
bin/perf-flamegraph
Symbolic link
|
@ -0,0 +1 @@
|
|||
__dispatch.sh
|
2
third_party/default.nix
vendored
2
third_party/default.nix
vendored
|
@ -72,6 +72,7 @@ let
|
|||
fira
|
||||
fira-code
|
||||
fira-mono
|
||||
flamegraph
|
||||
fontconfig
|
||||
freetype
|
||||
gettext
|
||||
|
@ -92,6 +93,7 @@ let
|
|||
kontemplate
|
||||
lib
|
||||
libredirect
|
||||
linuxPackages
|
||||
luajit
|
||||
lutris
|
||||
makeFontsConf
|
||||
|
|
12
tools/perf-flamegraph.nix
Normal file
12
tools/perf-flamegraph.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Script that collects perf timing for the execution of a command and writes a
|
||||
# flamegraph to stdout
|
||||
{ pkgs, ... }:
|
||||
|
||||
pkgs.writeShellScriptBin "perf-flamegraph" ''
|
||||
set -euo pipefail
|
||||
|
||||
${pkgs.linuxPackages.perf}/bin/perf record -g -a -F max "$@"
|
||||
${pkgs.linuxPackages.perf}/bin/perf script \
|
||||
| ${pkgs.flamegraph}/bin/stackcollapse-perf.pl \
|
||||
| ${pkgs.flamegraph}/bin/flamegraph.pl
|
||||
''
|
Loading…
Reference in a new issue