forked from gormanm/mmtests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile-disabled-hooks-operf.sh
55 lines (47 loc) · 1.67 KB
/
profile-disabled-hooks-operf.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
install-depends oprofile recode
if [ "$SAMPLE_CYCLE_FACTOR" = "" ]; then
SAMPLE_CYCLE_FACTOR=1
fi
CALLGRAPH=
if [ "$OPROFILE_REPORT_CALLGRAPH" != "" ]; then
CALLGRAPH=$OPROFILE_REPORT_CALLGRAPH
CALLGRAPH_SWITCH=--callgraph
if [ $SAMPLE_CYCLE_FACTOR -lt 15 ]; then
SAMPLE_CYCLE_FACTOR=15
fi
fi
# Create profiling hooks
PROFILE_TITLE="timer"
echo "#!/bin/bash" > monitor-pre-hook
case `uname -m` in
i?86)
echo "operf_start.sh $CALLGRAPH_SWITCH $CALLGRAPH --sample-cycle-factor $SAMPLE_CYCLE_FACTOR --event timer &" >> monitor-pre-hook
echo "echo \$! > operf.pid" >> monitor-pre-hook
export PROFILE_EVENTS=timer
;;
x86_64)
echo "operf_start.sh $CALLGRAPH_SWITCH $CALLGRAPH --sample-cycle-factor $SAMPLE_CYCLE_FACTOR --event timer &" >> monitor-pre-hook
echo "echo \$! > operf.pid" >> monitor-pre-hook
export PROFILE_EVENTS=timer
;;
ppc64)
echo "operf_start.sh $CALLGRAPH_SWITCH $CALLGRAPH --sample-cycle-factor $SAMPLE_CYCLE_FACTOR --event timer &" >> monitor-pre-hook
echo "echo \$! > operf.pid" >> monitor-pre-hook
export PROFILE_EVENTS=timer
;;
*)
echo Unrecognised architecture
exit -1
;;
esac
echo "sleep 5" >> monitor-pre-hook
echo "#!/bin/bash" > monitor-post-hook
echo 'OPERFPID=`cat operf.pid`' >> monitor-post-hook
echo "kill -SIGINT \$OPERFPID" >> monitor-post-hook
echo "while [[ -f operf.pid ]]; do sleep 1; done" >> monitor-post-hook
echo "oprofile_report.sh > \$1/oprofile-\$2-report-$PROFILE_TITLE.txt" >> monitor-post-hook
echo "rm -rf oprofile_data" >> monitor-post-hook
echo "#!/bin/bash" > monitor-cleanup-hook
echo "rm \$1/oprofile-\$2-report-$PROFILE_TITLE.txt" >> monitor-cleanup-hook
echo "#!/bin/bash" > monitor-reset
chmod u+x monitor-*