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)
|
|
|
|
|
|
|
|
# Make sure perf is available.
|
|
|
|
if [ ! -x "$(command -v perf)" ]
|
|
|
|
then
|
2020-01-26 18:30:23 -05:00
|
|
|
echo "Cannot find perf, please make sure it's installed."
|
2018-12-08 15:28:57 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-01-26 18:30:23 -05:00
|
|
|
# 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
|
2016-10-09 00:30:21 -04:00
|
|
|
|
2020-01-26 18:30:23 -05:00
|
|
|
# Create flamegraph
|
|
|
|
cargo flamegraph --bin=alacritty -- $@
|
|
|
|
|
2024-05-24 13:32:11 -04:00
|
|
|
# Uninstall cargo-flamegraph if it has been installed with this script
|
2020-01-26 18:30:23 -05:00
|
|
|
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
|