-
Notifications
You must be signed in to change notification settings - Fork 261
/
Copy pathperf-java-flames
executable file
·40 lines (31 loc) · 1.09 KB
/
perf-java-flames
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
set -e
#set -x
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
PID=$1
if [ -z $PERF_JAVA_TMP ]; then
PERF_JAVA_TMP=/tmp
fi
STACKS=$PERF_JAVA_TMP/out-$PID.stacks
COLLAPSED=$PERF_JAVA_TMP/out-$PID.collapsed
PERF_MAP_DIR=$(dirname $(readlink -f $0))/..
#if [ -n $FLAMEGRAPH_DIR ]; then
# FLAMEGRAPH_DIR=/home/johannes/git/opensource/FlameGraph
#fi
if [ ! -x $FLAMEGRAPH_DIR/stackcollapse-perf.pl ]; then
echo "FlameGraph executable not found at '$FLAMEGRAPH_DIR/stackcollapse-perf.pl'. Please set FLAMEGRAPH_DIR to the root of the clone of https://github.com/brendangregg/FlameGraph."
exit
fi
if [ -z $PERF_DATA_FILE ]; then
PERF_DATA_FILE=$PERF_JAVA_TMP/perf-$PID.data
fi
if [ -z $PERF_FLAME_OUTPUT ]; then
PERF_FLAME_OUTPUT=flamegraph-$PID.svg
fi
$PERF_MAP_DIR/bin/perf-java-record-stack $*
perf script -i $PERF_DATA_FILE > $STACKS
$FLAMEGRAPH_DIR/stackcollapse-perf.pl $STACKS | tee $COLLAPSED | $FLAMEGRAPH_DIR/flamegraph.pl --color=java > $PERF_FLAME_OUTPUT
echo "Flame graph SVG written to PERF_FLAME_OUTPUT='`readlink -f $PERF_FLAME_OUTPUT`'."