-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathprofile
More file actions
executable file
·61 lines (44 loc) · 1.56 KB
/
profile
File metadata and controls
executable file
·61 lines (44 loc) · 1.56 KB
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
57
58
59
60
#!/bin/bash
event=cpu
format=flat
seconds=12
usage1="Usage: profile [-h] [-s seconds] [-w seconds] [-e event] [-f format] [--] executable args"
usage2="Usage: profile [options] executable args\nOptions:\n\t[-h] [-s seconds] [-w seconds]\n\t[-e cpu|alloc|nativemem|lock|cache-misses]\n\t[-f flat|traces|collapsed|flamegraph|tree|jfr|otlp]"
while getopts s:f:e:o:w:h opt
do
case $opt in
s) seconds=$OPTARG ;;
f) format=$OPTARG ;;
e) event=$OPTARG ;;
o) stub=$OPTARG ;;
w) warmup=$OPTARG ;;
h) echo -e $usage2 && exit 0 ;;
--) break ;;
\?) echo $usage1 && exit 1 ;;
# :) echo $usage1 && exit 2 ;;
esac
done
shift $((OPTIND-1))
executable=$1
arguments=${@:2}
which asprof >& /dev/null
[ "$?" -ne 0 ] && echo 'ERROR: asprof is not in $PATH.' && echo -e $usage2 && exit 3
which $executable >& /dev/null
[ "$?" -ne 0 ] && echo "ERROR: $executable is not in \$PATH." && echo -e $usage2 && exit 4
echo "Running asprof on '$executable $arguments' ..."
set -e
$executable $arguments >& asprof_$stub.log
pid_bash=$!
echo PID1=$pid_bash
sleep 5
pid_java=$(pgrep -P "$pid_bash")
echo PID2=$pid_java
ps waux && ps -p $pid_java
echo "Waiting for $warmup seconds of warmup ..."
for x in $(seq $warmup); do let y=$warmup-$x && echo -e -n "\r$y ..." && sleep 1; done
# This 42 is probably for recon-util:
tail -n 42 asprof_$stub.log
asprof --title "Coatjava:asprof:$executable:$event" -e $event \
-d $seconds -o $format -f asprof_${format}_${event}_$stub $pid_java
kill -9 $pid_java
rm -f asprof_$stub.hipo