forked from gormanm/mmtests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile-disabled-hooks-d.sh
52 lines (42 loc) · 1.37 KB
/
profile-disabled-hooks-d.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
echo '#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
int main() {
int fd;
char buf[64];
int bytes_write, bytes_written;
fd = open("/tmp/mmtests.perf.pid", O_CREAT|O_TRUNC|O_WRONLY);
if (fd == -1) {
perror("open");
exit(-1);
}
snprintf(buf, sizeof(buf), "%d", getpid());
bytes_written = 0;
bytes_write = strlen(buf);
while (bytes_written != bytes_write) {
bytes_written += write(fd, buf + bytes_written, bytes_write - bytes_written);
}
close(fd);
pause();
return 0;
}' > /tmp/mmtests-wait.c
# Create profiling hooks
PROFILE_TITLE="timer"
export PROFILE_EVENTS=timer
gcc -Wall /tmp/mmtests-wait.c -o /tmp/mmtests-wait || exit $SHELLPACK_ERROR
echo "#!/bin/bash" > monitor-pre-hook
echo "perf record -o \$1/oprofile-\$2-report-${PROFILE_TITLE}.data -g -a /tmp/mmtests-wait &" >> monitor-pre-hook
echo "#!/bin/bash" > monitor-post-hook
echo 'kill `cat /tmp/mmtests.perf.pid`' >> monitor-post-hook
echo "sleep 5" >> monitor-post-hook
echo "perf report -i \$1/oprofile-\$2-report-${PROFILE_TITLE}.data > \$1/oprofile-\$2-report-${PROFILE_TITLE}.txt" >> monitor-post-hook
echo "#!/bin/bash" > monitor-cleanup-hook
echo "#!/bin/bash" > monitor-reset
echo 'kill `cat /tmp/mmtests.perf.pid`' >> monitor-reset
echo "sleep 5" >> monitor-reset
chmod u+x monitor-*