Add script for creating flamegraph with perf

Resolves #8
This commit is contained in:
Joe Wilm 2016-10-08 21:30:21 -07:00
parent b91c90dc34
commit b80abe9a54
4 changed files with 51 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
target
FlameGraph

20
scripts/README.md Normal file
View File

@ -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.

19
scripts/create-flamegraph.sh Executable file
View File

@ -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"

11
scripts/ubuntu-install-perf.sh Executable file
View File

@ -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