summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2016-10-08 21:30:21 -0700
committerJoe Wilm <joe@jwilm.com>2016-10-08 21:30:21 -0700
commitb80abe9a54acaea65c5ed4e676a9fbc8e211fd40 (patch)
tree3f3080db9549194652012001c36ee4721098bed1 /scripts
parentb91c90dc34cfb2a1381f3bc3da85a7c223ac480f (diff)
Add script for creating flamegraph with perf
Resolves #8
Diffstat (limited to 'scripts')
-rw-r--r--scripts/README.md20
-rwxr-xr-xscripts/create-flamegraph.sh19
-rwxr-xr-xscripts/ubuntu-install-perf.sh11
3 files changed, 50 insertions, 0 deletions
diff --git a/scripts/README.md b/scripts/README.md
new file mode 100644
index 00000000..39897c30
--- /dev/null
+++ b/scripts/README.md
@@ -0,0 +1,20 @@
+scripts
+=======
+
+There are two scripts included at the time this README was written, and they
+both support flamegraph generation on Ubuntu. The first script installs the
+required dependencies:
+
+```sh
+scripts/ubuntu-install-perf.sh
+```
+
+The second script will run Alacritty while recording call stacks. After the
+Alacritty process exits, a flamegraph will be generated and its URI printed.
+
+```sh
+scripts/create-flamegraph.sh
+```
+
+**NOTE**: The _create-flamegraph.sh_ script is intended to be run from the
+alacritty project root.
diff --git a/scripts/create-flamegraph.sh b/scripts/create-flamegraph.sh
new file mode 100755
index 00000000..8c03aa28
--- /dev/null
+++ b/scripts/create-flamegraph.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+# Make sure FlameGraph scripts are available
+if [ ! -e ./FlameGraph ]
+then
+ git clone https://github.com/BrendanGregg/FlameGraph
+fi
+
+if [ ! -e target/release/alacritty ]
+then
+ echo "Must build alacritty first: cargo build --release"
+ exit 1
+fi
+
+# This will block while alacritty runs
+perf record -g -F 99 target/release/alacritty
+perf script | ./FlameGraph/stackcollapse-perf.pl | ./FlameGraph/flamegraph.pl --width 1920 > alacritty.svg
+
+echo "Flame graph created at file://$(pwd)/alacritty.svg"
diff --git a/scripts/ubuntu-install-perf.sh b/scripts/ubuntu-install-perf.sh
new file mode 100755
index 00000000..85670039
--- /dev/null
+++ b/scripts/ubuntu-install-perf.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+set -v
+
+# Get kernel info
+UNAME=$(uname -r)
+
+# Install linux tools for the perf binary
+sudo apt-get install -y \
+ linux-tools-common \
+ linux-tools-generic \
+ linux-tools-$UNAME