Skip to content

Commit 7aec337

Browse files
committed
add flexibility
1 parent 5cb1f49 commit 7aec337

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

libexec/profile

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
11
#!/bin/bash
22

3-
set -e
4-
5-
# configure:
6-
event=cpu #nativemem
3+
event=cpu
74
format=flat
8-
nevents=1000
95
seconds=12
10-
yaml=etc/services/data-ai-uber.yml
11-
while getopts y:n:f:e:s:h opt
6+
usage="Usage: profile [-h] [-s seconds] [-w seconds] [-e event] [-f format] [--] executable args"
7+
usage2="Usage: profile [-h] [-s seconds] [-w seconds] [-e cpu|alloc|nativemem|lock|cache-misses] [-f flat|traces|collapsed|flamegraph|tree|jfr|otlp] [--] executable args"
8+
9+
while getopts s:f:e:o:w:h opt
1210
do
1311
case $opt in
1412
s) seconds=$OPTARG ;;
15-
y) yaml=$OPTARG ;;
16-
n) nevents=$OPTARG ;;
1713
f) format=$OPTARG ;;
1814
e) event=$OPTARG ;;
19-
h) echo "\nUsage: profile [-y YAML] [-n #] [-e EVENT] datafile" && exit 0 ;;
15+
o) stub=$OPTARG ;;
16+
w) warmup=$OPTARG ;;
17+
h) echo $usage2 && exit 0 ;;
18+
--) break ;;
19+
\?) echo $usage && exit 1 ;;
20+
# :) echo $usage && exit 2 ;;
2021
esac
2122
done
23+
2224
shift $((OPTIND-1))
23-
data=$1
24-
stub=$(basename $data)
25-
stub=${stub%%.*}
25+
executable=$1
26+
arguments=${@:2}
2627

2728
which asprof >& /dev/null
28-
[ "$?" -ne 0 ] && echo 'ERROR: asprof is not in $PATH.' && exit 9
29+
[ "$?" -ne 0 ] && echo 'ERROR: asprof is not in $PATH.' && exit 3
30+
31+
which $executable >& /dev/null
32+
[ "$?" -ne 0 ] && echo "ERROR: $executable is not in \$PATH." && exit 4
33+
34+
echo "Running asprof on '$executable $arguments' ..."
35+
36+
set -e
2937

30-
which recon-util >& /dev/null
31-
[ "$?" -ne 0 ] && echo 'ERROR: recon-util is not in $PATH.' && exit 9
38+
$executable $arguments >& asprof_$stub.log
3239

33-
recon-util -y $yaml -n $nevents -o pro_$stub.hipo -i $data >& pro_$stub.log &
3440
pid_bash=$!
3541

3642
echo PID1=$pid_bash
@@ -41,14 +47,15 @@ echo PID2=$pid_java
4147

4248
ps waux && ps -p $pid_java
4349

44-
echo "Waiting for 60 seconds of CoatJava warmup ..."
45-
for x in $(seq 60); do let y=60-$x && echo -e -n "\r$y ..." && sleep 1; done
50+
echo "Waiting for $warmup seconds of warmup ..."
51+
for x in $(seq $warmup); do let y=$warmup-$x && echo -e -n "\r$y ..." && sleep 1; done
4652

47-
tail -n 42 pro_$stub.log
53+
# This 42 is probably for recon-util:
54+
tail -n 42 asprof_$stub.log
4855

49-
asprof --title "Coatjava - asprof - $event" -e $event \
50-
-d $seconds -o $format -f pro_${format}_${event}_$stub $pid_java
56+
asprof --title "Coatjava:asprof:$executable:$event" -e $event \
57+
-d $seconds -o $format -f asprof_${format}_${event}_$stub $pid_java
5158

5259
kill -9 $pid_java
53-
rm -f pro_$stub.hipo
60+
rm -f asprof_$stub.hipo
5461

0 commit comments

Comments
 (0)