-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-power-benchmark.sh
executable file
·60 lines (52 loc) · 2.29 KB
/
run-power-benchmark.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
56
57
58
59
60
#!/usr/bin/env bash
testName=${1}
testLabel=${2}
executionPath=$(dirname $(realpath -s $0))
# Default number of times to run the tests
benchmarkRuns=4
kernelPerf=$(cat /proc/sys/kernel/perf_event_paranoid)
perfCommand="perf stat -e power/energy-psys/,power/energy-pkg/,power/energy-cores/,power/energy-gpu/,power/energy-ram/"
# Make benchmark function also report the power average power data
POWER_BENCHMARK=1
if [ ${kernelPerf} -ge 1 ];
then
echo "You need to set /proc/sys/kernel/perf_event_paranoid to 0 or lower to get power events without sudo."
exit 1
fi
# If installed, change the path to where it is actually installed
if [ ! -f ${executionPath}/common/variables.sh ]; then
if [ -f /usr/share/benchmarking-tools/common/variables.sh ]; then
executionPath=/usr/share/benchmarking-tools
else
serpentFail "Can't find benchmarking-tools directory."
exit 1
fi
fi
# Import shared variables
. ${executionPath}/common/variables.sh
. ${executionPath}/common/functions.sh
printInfo "Preparing benchmark environment"
. ${executionPath}/common/prepare-benchmark.sh
. ${executionPath}/common/benchmark.sh
for run in $(seq 1 1 ${benchmarkRuns}); do
printInfo "Begin iteration $run of ${benchmarkRuns}"
for test in "${!benchmarkTest[@]}"; do
# Wait to settle system after previous test
sleep 10
# If possible run the repeats through perf
if [ -z "${benchmarkPretest[$test]}" ] && [ -z "${benchmarkPosttest[$test]}" ] && [ -z "${DATA_BENCHMARK}" ]; then
tmpResult=$(runBenchmarkRepeat "${benchmarkTest[$test]}")
else
tmpResult=$(runBenchmark "${benchmarkTest[$test]}")
fi
testResult=$(echo ${tmpResult} | cut -f1 -d' ')
testValidation=$(runCommands "${benchmarkValidation[$test]}")
testPsys=$(echo ${tmpResult} | cut -f2 -d' ')
testPkg=$(echo ${tmpResult} | cut -f3 -d' ')
testCores=$(echo ${tmpResult} | cut -f4 -d' ')
testGPU=$(echo ${tmpResult} | cut -f5 -d' ')
testRam=$(echo ${tmpResult} | cut -f6 -d' ')
# Record results
echo "$testName,$testLabel,$testDistro,$testKernel,$testDate,${benchmarkLabels[$test]},$testResult,$testValidation,$testPsys,$testPkg,$testCores,$testGPU,$testRam" >> ${BT_RESULTS_DIR}/results-power.csv
done
done