Last active
May 30, 2018 14:17
-
-
Save sbz/fed2f5f441653a4e231eac9639d51339 to your computer and use it in GitHub Desktop.
Run pyflame against your python code, to profile it and generate a flamegraph (here it's against singularity-monitor)
This file contains hidden or 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 | |
sudo apt-get install -y autoconf automake autotools-dev g++ pkg-config python-dev python3-dev libtool make | |
[ ! -f ./flamegraph.pl ] && { | |
curl -O https://raw.githubusercontent.com/brendangregg/FlameGraph/master/flamegraph.pl | |
} | |
[ ! -f /usr/local/bin/pyflame -o ! -d pyflame ] && { | |
git clone https://github.com/uber/pyflame.git | |
cd pyflame | |
./autogen.sh | |
./configure --prefix=/usr/local | |
make | |
sudo make install | |
} | |
process="singularity-monitor" | |
pid=`pgrep ${process%%-*}` | |
echo "Dump Stack Strace" | |
sudo /usr/local/bin/pyflame -p ${pid} -d | |
seconds=180 | |
echo Launching ${seconds} seconds profiling... /usr/local/bin/pyflame -s ${seconds} -r 0.01 -p ${pid} | |
sudo /usr/local/bin/pyflame -s ${seconds} -r 0.01 -p ${pid} -o ${process}.prof --threads | |
wait $! | |
perl ./flamegraph.pl < ${process}.prof > ${process}.svg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment