2016-10-09 00:30:21 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-12-08 15:28:57 -05:00
|
|
|
# The full path to the script directory, regardless of pwd.
|
|
|
|
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
|
|
|
|
# Current UNIX time.
|
|
|
|
TIME=$(date +%s)
|
|
|
|
|
|
|
|
# Make sure FlameGraph scripts are available.
|
|
|
|
if [ ! -e $DIR/FlameGraph ]
|
2016-10-09 00:30:21 -04:00
|
|
|
then
|
2018-12-08 15:28:57 -05:00
|
|
|
git clone https://github.com/BrendanGregg/FlameGraph \
|
|
|
|
$DIR/create-flamegraph/FlameGraph
|
2016-10-09 00:30:21 -04:00
|
|
|
fi
|
|
|
|
|
2018-12-08 15:28:57 -05:00
|
|
|
# Make sure a release build of Alacritty is available.
|
|
|
|
if [ ! -e $DIR/../target/release/alacritty ]
|
2016-10-09 00:30:21 -04:00
|
|
|
then
|
|
|
|
echo "Must build alacritty first: cargo build --release"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-12-08 15:28:57 -05:00
|
|
|
# Make sure perf is available.
|
|
|
|
if [ ! -x "$(command -v perf)" ]
|
|
|
|
then
|
|
|
|
echo "Cannot find perf, please make sure it's installed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Run perf, this will block while alacritty runs.
|
|
|
|
perf record -g -F 99 $DIR/../target/release/alacritty
|
|
|
|
perf script \
|
|
|
|
| $DIR/create-flamegraph/FlameGraph/stackcollapse-perf.pl \
|
|
|
|
| $DIR/create-flamegraph/FlameGraph/flamegraph.pl --width 1920 \
|
|
|
|
> flame-$TIME.svg
|
2016-10-09 00:30:21 -04:00
|
|
|
|
2018-12-08 15:28:57 -05:00
|
|
|
# Tell users where the file is.
|
|
|
|
echo "Flame graph created at: file://$(pwd)/flame-$TIME.svg"
|