-
-
Save npenkov/fe61010a8b352fd09037e9af254f6502 to your computer and use it in GitHub Desktop.
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 | |
# Usage: ./gen.sh collected-stacks.txt | |
TMPSTACKS=/tmp/flamegraph-stacks-collapsed.txt | |
TMPPALETTE=/tmp/flamegraph-palette.map | |
./stackcollapse-jstack.pl $1 > $TMPSTACKS | |
# 1st run - hot: default | |
./flamegraph.pl --cp $TMPSTACKS > stacks.svg | |
# 2nd run - blue: I/O | |
cp palette.map $TMPPALETTE | |
cat $TMPPALETTE | grep -v '\.read' | grep -v '\.write' | grep -v 'socketRead' | grep -v 'socketWrite' | grep -v 'socketAccept' > palette.map | |
./flamegraph.pl --cp --colors=io $TMPSTACKS > stacks.svg | |
echo "Done! Now see the output in stacks.svg" |
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/sh | |
# Usage: ./profile.sh pid output.txt | |
PROFILED_PID=$1 | |
OUTPUT_FILE=$2 | |
echo "Getting stacktraces from process $PROFILED_PID... Will stop on ^C or when the process exits." | |
rm -f "$OUTPUT_FILE" | |
while true; do | |
jstack "$PROFILED_PID" >> "$OUTPUT_FILE" && sleep 0.01 || break | |
done | |
echo | |
echo "Done! Stacks saved to $OUTPUT_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment