Created
October 29, 2022 10:45
-
-
Save omerkaya1/f0dbcdc90f6c1ab4087a4ad0217f132f to your computer and use it in GitHub Desktop.
Simple script to collect Go app's profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BRANCH=$(git branch --show-current) | |
COMMIT_HASH=$(git rev-parse --short HEAD) | |
for i in {1..5} ; do | |
printf "Phase %s\n" "$i" | |
if ! curl -s "localhost:8000/debug/pprof/heap" > mem-"$BRANCH"-"$COMMIT_HASH"-"$(date "+%Y-%m-%d-%H-%M-%S")".pprof | |
then | |
echo "failed to get mem profile" | |
fi | |
if ! curl -s "localhost:8000/debug/pprof/profile?seconds=5" > cpu-"$BRANCH"-"$COMMIT_HASH"-"$(date "+%Y-%m-%d-%H-%M-%S")".pprof | |
then | |
echo "failed to get cpu profile" | |
fi | |
# TODO: check the error! | |
if ! curl -s "localhost:8000/debug/pprof/goroutine?seconds=5" > gr-"$BRANCH"-"$COMMIT_HASH"-"$(date "+%Y-%m-%d-%H-%M-%S")".pprof | |
then | |
echo "failed to get goroutine profile" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment