-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_benchmark_official.sh
executable file
·169 lines (152 loc) · 4.75 KB
/
run_benchmark_official.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
SIMDJSON_DIR=$SCRIPT_DIR/simdjson
if [ ! -d $SIMDJSON_DIR ]; then
cd $(dirname $SIMDJSON_DIR)
git clone https://github.com/simdjson/simdjson
fi
function bench_results() {
host=$1
compiler=$2
base_version=$3
commit=$4
variant=$5
benchmarks=$6
case $compiler in
clang6)
export CXX=clang++-6.0 CC=clang-6.0
;;
clang7)
export CXX=clang++-7 CC=clang-7
;;
clang8)
export CXX=clang++-8 CC=clang-8
;;
clang9)
export CXX=clang++-9 CC=clang-9
;;
clang10)
export CXX=clang++-10 CC=clang-10
;;
clang11)
export CXX=clang++-11 CC=clang-11
;;
gcc7)
export CXX=g++-7 CC=gcc-7
;;
gcc8)
export CXX=g++-8 CC=gcc-8
;;
gcc9)
export CXX=g++-9 CC=gcc-9
;;
gcc10.2)
export CXX=g++-10 CC=gcc-10
;;
*)
echo "Unknown compiler $compiler"
exit 1
;;
esac
suffix="-$variant"
case $variant in
release)
suffix=""
;;
development)
# This is a basic default release build with development aids
cmake_flags="-DSIMDJSON_DEVELOPMENT_CHECKS=1"
;;
debug)
cmake_flags="-DCMAKE_BUILD_TYPE=Debug"
;;
native)
cmake_flags="-DCMAKE_CXX_FLAGS=-march=native"
;;
fallback)
cmake_flags="-DSIMDJSON_IMPLEMENTATION=fallback"
;;
westmere)
cmake_flags="-DSIMDJSON_EXCLUDE_IMPLEMENTATION=haswell"
;;
*)
echo "Unknown variant $variant"
exit 1
;;
esac
#
# Create base directory file will live in
#
base_dir=$SCRIPT_DIR/$base_version
cd $SCRIPT_DIR/simdjson
# Error if commit is not a child of the base version
if ! git merge-base --is-ancestor $base_version $commit; then
echo "Commit $commit is not derived from $base_version!"
exit 1;
fi
if git merge-base --is-ancestor $commit master; then
# If it's *past* the base version, use the number of commits past the base version for the directory.
commits_past_version=$(git rev-list --count --first-parent $base_version...$commit)
if [ "$commits_past_version" -ne "0" ]; then
echo "Commit $commit is $commits_past_version commits past $base_version."
base_dir="$base_dir/$commits_past_version"
fi
else
# If it's not on master, it's a branch ... use the commit id.
commit_sha=$(git rev-list -n 1 $commit)
echo "$commit ($commit_sha) is not on master. Setting base_dir to commit id $commit_sha..."
base_dir="$base_dir/$commit_sha"
fi
mkdir -p $base_dir
#
# Run benchmark (unless it's already been run)
#
file_base=$base_dir/$host-$compiler$suffix
json_file=$file_base.json
if [ -f $json_file ] && [ "$FORCE" = "" ]; then
echo $json_file already generated
else
echo run_benchmark $commit $json_file \"$cmake_flags\" \"$benchmarks\" \> $file_base.out 2\>\&1
run_benchmark $commit $json_file "$cmake_flags" "$benchmarks" > $file_base.out 2>&1
echo
echo $json_file
echo
fi
}
function run_benchmark() {
commit=$1
json_file=$2
cmake_flags=$3
benchmarks=$4
echo "run_benchmark: $commit $json_file \"$cmake_flags\" \"$benchmarks\""
# Build
echo git reset --hard $commit
git reset --hard $commit
mkdir -p build
cd build
cmake_flags="$cmake_flags -DCMAKE_RULE_MESSAGES:BOOL=OFF -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
echo cmake $cmake_flags ..
cmake $cmake_flags ..
echo make -j --no-print-directory bench_ondemand
make -j --no-print-directory bench_ondemand
# Run the benchmark
echo benchmark/bench_ondemand --benchmark_counters_tabular=true --benchmark_out=$json_file --benchmark_out_format=json --benchmark_filter="$benchmarks"
benchmark/bench_ondemand --benchmark_counters_tabular=true --benchmark_out=$json_file --benchmark_out_format=json --benchmark_filter="$benchmarks"
}
host=$1
base_version=$2
commits=${3:-"$base_version"}
compilers=${4:-clang11}
variants=${5:-production}
benchmarks=${6:-simdjson}
cd $SCRIPT_DIR/simdjson
git remote update
for compiler in $compilers; do
for variant in $variants; do
rm -rf $SCRIPT_DIR/simdjson/build
for commit in $commits; do
bench_results $host $compiler $base_version $commit $variant "$benchmarks"
done
done
done