summaryrefslogtreecommitdiffstats
path: root/scripts/create-flamegraph.sh
diff options
context:
space:
mode:
authorNathan Lilienthal <nathan@nixpulvis.com>2018-12-08 15:28:57 -0500
committerChristian Duerr <chrisduerr@users.noreply.github.com>2018-12-08 20:28:57 +0000
commitf32facfbfd3d46b76744d118fd2fa5123501f900 (patch)
treea2b8835a62f80faf24d6bd120c6622a317b26b56 /scripts/create-flamegraph.sh
parent6b61e967390b2fa4a24f962c4771cdd82e0e9de3 (diff)
Refactor Alacritty scripts
This includes some changes to the scripts `README.md` to provide some more information on the different Alacritty scripts. A new script for testing the 24 bit support of Alacritty has been added with the `24-bit-color.sh` name. This should help with troubleshooting truecolor support issues. Since `perf` is a standard tool which is available in the official repositories for most distributions, it doesn't make much sense to provide an installation script specifically for Ubuntu. As a result of this, the script has been removed.
Diffstat (limited to 'scripts/create-flamegraph.sh')
-rwxr-xr-xscripts/create-flamegraph.sh35
1 files changed, 27 insertions, 8 deletions
diff --git a/scripts/create-flamegraph.sh b/scripts/create-flamegraph.sh
index 8c03aa28..71af6a93 100755
--- a/scripts/create-flamegraph.sh
+++ b/scripts/create-flamegraph.sh
@@ -1,19 +1,38 @@
#!/usr/bin/env bash
-# Make sure FlameGraph scripts are available
-if [ ! -e ./FlameGraph ]
+# 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
+ git clone https://github.com/BrendanGregg/FlameGraph \
+ $DIR/create-flamegraph/FlameGraph
fi
-if [ ! -e target/release/alacritty ]
+# 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
-# 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
+# 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
-echo "Flame graph created at file://$(pwd)/alacritty.svg"
+# Tell users where the file is.
+echo "Flame graph created at: file://$(pwd)/flame-$TIME.svg"