-
Notifications
You must be signed in to change notification settings - Fork 0
/
pgo_test.sh
executable file
·43 lines (35 loc) · 1.04 KB
/
pgo_test.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
#!/bin/bash
# command to be used for scanning and measuring PGO
# (--info and --error set to @stdout keeps stderr for benchmark results only)
DEFAULT_COMMAND="./tml --bin --info @stdout --error @stdout < tml.g"
# or pass command as a first argument string
COMMAND="${1:-${DEFAULT_COMMAND}}"
function benchmark {
/usr/bin/time -f '[user]=%U [system]=%S [cpu]=%P [mem]=%M' $@
}
# $1 = BUILD_TYPE (Release, PgoScan or PgoRun)
function build_and_run {
DIR=$(pwd)
./build.sh $1 && cd build-Release && \
eval "benchmark $COMMAND 2> ./pgo.stats/$1.txt"
cd $DIR
}
function initialize {
mkdir -p ./build-Release/pgo.stats && \
rm -f ./build-Release/pgo.stats/*.txt && \
cp src/tml.g build-Release/
}
function run_tests {
for RUN in {Release,PgoScan,PgoRun};
do
build_and_run $RUN
done && rm -rf ./build-Release/pgo
}
function print_results {
echo && echo "PGO test results of: '$COMMAND'" && echo && \
for RUN in {Release,PgoRun};
do
echo -n "$RUN:" && cat "./build-Release/pgo.stats/$RUN.txt"
done && echo
}
initialize && run_tests && print_results