summaryrefslogtreecommitdiff
path: root/mod/tools/perf-flamegraph.nix
diff options
context:
space:
mode:
authorKleidi Bujari <mail@4kb.net>2025-01-24 12:14:23 -0500
committerKleidi Bujari <mail@4kb.net>2025-01-24 12:14:23 -0500
commit32f4cb5cbba313b7af2fce46139c04d9469cb72a (patch)
tree3cc7da05d4320a8f89a726d67811110771dae1bf /mod/tools/perf-flamegraph.nix
parent8271e2b89180578ab4dd9ed9eb37142254e5a148 (diff)
downloaddepot-32f4cb5cbba313b7af2fce46139c04d9469cb72a.tar.gz
depot-32f4cb5cbba313b7af2fce46139c04d9469cb72a.tar.bz2
depot-32f4cb5cbba313b7af2fce46139c04d9469cb72a.zip
25-jan sprint
Diffstat (limited to 'mod/tools/perf-flamegraph.nix')
-rw-r--r--mod/tools/perf-flamegraph.nix12
1 files changed, 12 insertions, 0 deletions
diff --git a/mod/tools/perf-flamegraph.nix b/mod/tools/perf-flamegraph.nix
new file mode 100644
index 0000000..b472b74
--- /dev/null
+++ b/mod/tools/perf-flamegraph.nix
@@ -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 --call-graph dwarf -F max "$@"
+ ${pkgs.linuxPackages.perf}/bin/perf script \
+ | ${pkgs.flamegraph}/bin/stackcollapse-perf.pl \
+ | ${pkgs.flamegraph}/bin/flamegraph.pl
+''