aboutsummaryrefslogtreecommitdiff
path: root/scripts/create-flamegraph.sh
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-01-27 00:30:23 +0100
committerKirill Chibisov <contact@kchibisov.com>2020-01-27 02:30:23 +0300
commit0f15dc05d9332bb9dc71bd9b70bc737da2dc33c5 (patch)
tree481e2fd0559aad8f588d0a9ac075ccfc47d4efb9 /scripts/create-flamegraph.sh
parent4cc6421daa4ff5976ab43c67110a7a80a36541e5 (diff)
downloadalacritty-0f15dc05d9332bb9dc71bd9b70bc737da2dc33c5.tar.gz
alacritty-0f15dc05d9332bb9dc71bd9b70bc737da2dc33c5.zip
Switch to flamegraph-rs script
This cleans up the Alacritty scripts a bit by removing some of them which are not recommended to be used anymore and switching from the official FlameGraph tool to the more specialized Rust FlameGraph implementation.
Diffstat (limited to 'scripts/create-flamegraph.sh')
-rwxr-xr-xscripts/create-flamegraph.sh45
1 files changed, 19 insertions, 26 deletions
diff --git a/scripts/create-flamegraph.sh b/scripts/create-flamegraph.sh
index 71af6a93..921cee8a 100755
--- a/scripts/create-flamegraph.sh
+++ b/scripts/create-flamegraph.sh
@@ -3,36 +3,29 @@
# 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 ]
-then
- git clone https://github.com/BrendanGregg/FlameGraph \
- $DIR/create-flamegraph/FlameGraph
-fi
-
-# Make sure a release build of Alacritty is available.
-if [ ! -e $DIR/../target/release/alacritty ]
-then
- echo "Must build alacritty first: cargo build --release"
- exit 1
-fi
-
# Make sure perf is available.
if [ ! -x "$(command -v perf)" ]
then
- echo "Cannot find perf, please make sure it's installed"
+ 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
+# Install cargo-flamegraph
+installed_flamegraph=0
+if [ ! -x "$(command -v cargo-flamegraph)" ]; then
+ echo "cargo-flamegraph not installed; installing ..."
+ cargo install flamegraph
+ installed_flamegraph=1
+fi
-# Tell users where the file is.
-echo "Flame graph created at: file://$(pwd)/flame-$TIME.svg"
+# Create flamegraph
+cargo flamegraph --bin=alacritty -- $@
+
+# Unintall cargo-flamegraph if it has been installed with this script
+if [ $installed_flamegraph == 1 ]; then
+ read -p "Would you like to uninstall cargo-flamegraph? [Y/n] " -n 1 -r
+ echo
+ if [[ "$REPLY" =~ ^[^Nn]*$ ]]; then
+ cargo uninstall flamegraph
+ fi
+fi