Created
March 6, 2017 21:20
-
-
Save aroben/65d67a3eb8942b4d1ec033e72437ac13 to your computer and use it in GitHub Desktop.
Script to generate flamegraphs from Ruby stackprof profiles
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 | |
# First generate a profile using https://github.com/tmm1/stackprof | |
# StackProf.run(raw: true, out: "tmp/stackprof.dump) { something_expensive } | |
# Then run this script | |
# $ stackprof-to-flamegraph tmp/stackprof.dump | |
set -e | |
if [ "$STACKCOLLAPSE" = "1" ]; then | |
template="/tmp/stackprof-$$" | |
stackcollapse="$template-stackcollapse.txt" | |
flamegraph="$template-flamegraph.svg" | |
width=4800 | |
stackprof --stackcollapse "$1" > "$stackcollapse" | |
stackprof-flamegraph.pl --hash --width $width --title "$1" "$stackcollapse" > "$flamegraph" | |
open -a Safari "$flamegraph" | |
else | |
stackprof --flamegraph "$1" > "$1.flamegraph" | |
stackprof --flamegraph-viewer "$1.flamegraph" | sed -e 's/^open //' | pbcopy | |
echo "URL copied to clipboard" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment