-
Notifications
You must be signed in to change notification settings - Fork 3
/
flame-gen.sh
56 lines (49 loc) · 1.05 KB
/
flame-gen.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
TMPDIR=./tmp_flame
rm -rf $TMPDIR 2> /dev/null
mkdir $TMPDIR 2> /dev/null
trap ctrl_c INT
profiling=""
function ctrl_c() {
if [ "$profiling" != "" ]
then
sh ./flame-svg-gen.sh $TMPTRACE
fi
exit
}
TMPTRACE=./tmp_flame/trace.txt
rm $TMPTRACE 2> /dev/null
pid=""
if [ "$1" == "" ]
then
echo "waiting for java process..."
while [ "$pid" == "" ]
do
#For Windows with Cygwin use this
#pid=`ps -W | grep java | grep -o [0-9]* | head -1`
pid=`ps | grep java | grep -v grep | grep -o [0-9]* | head -1`
if [ "$pid" != "" ]
then
break
fi
done
else
pid=$1;
fi
#For Windows with Cygwin use this
#processExists=`ps -pW $pid | grep $pid`
processExists=`ps -p $pid | grep $pid`
if [ "$processExists" != "" ]
then
echo "process found pid: $pid"
echo "profiling started, press ctrl+c to end and generate report"
profiling="true"
while true;
do
jstack $pid >> $TMPTRACE && sleep 0.001;
done
sh ./flame-svg-gen.sh $TMPTRACE
else
echo "process with id $pid doesn't exists"
fi
#echo "Done! please check Flame.svg"