-
Notifications
You must be signed in to change notification settings - Fork 191
/
Copy pathcheck_latest_benchmark_results.sh
executable file
·79 lines (66 loc) · 2.87 KB
/
check_latest_benchmark_results.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# Simple script to try and sanity check the results of the latest benchmark run.
set -eu
set -x
# Move to the root of the repository.
scriptdir=$(dirname "$(readlink -f "$0")")
rootdir=$(readlink -f "$scriptdir/..")
cd "$rootdir"
# Check that the results directory exists.
if ! [ -d results ]; then
echo "ERROR: Missing results directory" >&2
exit 1
fi
BENCHBASE_PROFILE="${BENCHBASE_PROFILE:-}"
benchmark="${1:-}"
if [ -z "$benchmark" ]; then
echo "ERROR: Missing benchmark argument." >&2
fi
config_file=$(ls -1t results/${benchmark}_*.config.xml | head -n1)
if [ -z "$config_file" ]; then
echo "ERROR: Failed to find $benchmark benchmark results files." >&2
exit 1
fi
ts=$(basename "$config_file" | sed -e "s/^${benchmark}_//" -e 's/\.config\.xml//')
summary_json="results/${benchmark}_${ts}.summary.json"
if ! type xmllint 2>/dev/null; then
# Attempt to install xmllint.
# TODO: Add support for non apt based systems.
sudo -n /bin/bash -c "apt-get update && apt-get install -y libxml2-utils" || true
fi
if ! type xmllint 2>/dev/null; then
echo "ERROR: Missing xmllint utility." >&2
exit 1
fi
# TODO: include warmup?
expected_runtime=$(xmllint --xpath '//works/work/time/text()' "$config_file" | awk '{ print sum=sum+$1 }' | tail -n1)
if xmllint --xpath '//works/work/serial/text()' "$config_file" | grep -q -x true; then
if [ -n "$expected_runtime" ]; then
echo "ERROR: Unhandled: Found expected runtime in config file for serial workloads." >&2
exit 1
fi
expected_query_count=$(xmllint --xpath '//works/work/weights/text()' "$config_file" | sed 's/,/\n/g' | grep -c -x 1 || true)
if xmllint --xpath '//works/work/weights/text()' "$config_file" | sed 's/,/\n/g' | grep -q -v '^[01]$'; then
echo "ERROR: Unsupported weight specification for serial workloads. Only 0,1 are handled currently." >&2
exit 1
fi
measured_requests=$(cat "$summary_json" | jq -e '.["Measured Requests"]')
if [ "$measured_requests" -ne "$expected_query_count" ]; then
echo "ERROR: Benchmark measured requests ($measured_requests) was less than expected ($expected_query_count) or failed to parse output." >&2
exit 1
else
echo "OK: Benchmark measured requests ($measured_requests) matched ($expected_query_count)."
fi
else
if [ -z "$expected_runtime" ]; then
echo "ERROR: Failed to find expected runtime in config file: $config_file" >&2
exit 1
fi
elapsed_time=$(cat "$summary_json" | jq -e '.["Elapsed Time (nanoseconds)"] / 1000000000 | round')
if [ "$elapsed_time" -lt "$expected_runtime" ]; then
echo "ERROR: Benchmark elapsed runtime ($elapsed_time) was less than expected ($expected_runtime) or failed to parse output." >&2
exit 1
else
echo "OK: Benchmark elapsed runtime ($elapsed_time) matched expected ($expected_runtime)."
fi
fi