Skip to content

Instantly share code, notes, and snippets.

@p0pr0ck5
Created March 7, 2017 23:53
Show Gist options
  • Save p0pr0ck5/7aaec068ce4d5d08e9839d2fa6cb973e to your computer and use it in GitHub Desktop.
Save p0pr0ck5/7aaec068ce4d5d08e9839d2fa6cb973e to your computer and use it in GitHub Desktop.
function profile_fw() {
pushd `pwd`
cd ~poprocks/code/Lua/lua-resty-waf
make
popd
title=$1
OPATH=$PATH
s=$(date +%s)
pid=$(pgrep nginx | tail -1)
pushd /home/poprocks/code/tools/stapxx
export PATH=$PWD:$PATH
echo "traces..."
./samples/ngx-lj-trace-exits.sxx -x $pid
echo "ljvm states..."
./samples/lj-vm-states.sxx -x $pid
echo "Timing info..."
./samples/ngx-lua-exec-time.sxx -x $pid
echo "Flame graph..."
#./samples/lj-lua-stacks.sxx --arg nojit=1 --skip-badvars -x $pid > ../fw_"$s".bt
#./samples/lj-lua-stacks.sxx --arg nointerp=1 --skip-badvars -x $pid > ../fw_"$s".bt
./samples/lj-lua-stacks.sxx --skip-badvars -x $pid > ../fw_"$s".bt
../FlameGraph/stackcollapse-stap.pl <(../nginx-systemtap-toolkit/fix-lua-bt ../fw_"$s".bt) > ../fw_"$s".cbt
../FlameGraph/flamegraph.pl --title=\"$title\" ../fw_"$s".cbt > ../flamegraphs/fw_"$title"_"$s".svg
rm ../fw_"$s".bt ../fw_"$s".cbt
export PATH=$OPATH
popd
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment