-
Notifications
You must be signed in to change notification settings - Fork 1
269 lines (262 loc) · 11.8 KB
/
Copy pathbenchmarks.yml
File metadata and controls
269 lines (262 loc) · 11.8 KB
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# ------------------------------------------------------------------------------
# Copyright Matt Borland 2026.
# Distributed under the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
# ------------------------------------------------------------------------------
#
# Runs the Boost.SafeNumbers Google Benchmark suites (test/benchmarks/*.cpp) in
# release mode across a spread of native runners. The benchmarks are built via
# CMake with -DBOOST_SAFE_NUMBERS_BUILD_BENCHMARKS=ON, which pulls Google
# Benchmark in with FetchContent. Each job emits per-suite JSON and a ready to
# paste AsciiDoc section (produced by test/benchmarks/render_results.py) as
# artifacts for the documentation benchmarks page.
name: Run Benchmarks
on:
push:
branches:
- master
- develop
- feature/**
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
concurrency:
group: ${{ format('{0}:{1}:benchmarks', github.repository, github.ref) }}
cancel-in-progress: true
env:
GIT_FETCH_JOBS: 8
# Repetitions plus the median aggregate keep the reported numbers stable; the
# report-aggregates-only flag keeps the JSON small.
BENCH_ARGS: "--benchmark_repetitions=5 --benchmark_min_time=0.10s --benchmark_report_aggregates_only=true --benchmark_out_format=json"
jobs:
linux:
name: ${{ matrix.title }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- title: Linux x64
os: ubuntu-latest
arch: x64
anchor: linux_x64
desc: "Run on the GitHub Actions `ubuntu-latest` runner using GCC 14 in release mode (`-O2`, pass:[C++]20)."
multilib: false
cmake_extra: ""
- title: Linux x86 (32-bit)
os: ubuntu-latest
arch: x86-32
anchor: linux_x86_32
desc: "Run on the GitHub Actions `ubuntu-latest` runner using GCC 14 targeting 32-bit x86 (`-m32`) in release mode (`-O2`, pass:[C++]20)."
multilib: true
cmake_extra: "-DCMAKE_CXX_FLAGS=-m32 -DCMAKE_C_FLAGS=-m32"
- title: Linux ARM64
os: ubuntu-24.04-arm
arch: arm64
anchor: linux_arm64
desc: "Run on the GitHub Actions `ubuntu-24.04-arm` runner using GCC 14 in release mode (`-O2`, pass:[C++]20)."
multilib: false
cmake_extra: ""
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v6
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y g++-14 cmake
if [ "${{ matrix.multilib }}" = "true" ]; then
sudo apt-get install -y g++-14-multilib
fi
- name: Setup Boost
run: |
LIBRARY=${GITHUB_REPOSITORY#*/}
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
cd ..
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" boost-root
cd boost-root
mkdir -p libs/$LIBRARY
# Exclude doc/: it carries an Antora examples symlink (which git-bash on
# Windows cannot recreate) and a large node_modules tree, neither of
# which the benchmark build or depinst need.
shopt -s extglob
cp -r "$GITHUB_WORKSPACE"/!(doc) libs/$LIBRARY/
git submodule update --init tools/boostdep
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" $LIBRARY
- name: Configure and build benchmarks
run: |
cd ../boost-root
cmake -S . -B __build__ \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \
-DBOOST_INCLUDE_LIBRARIES="$LIBRARY;safe_numerics;random" \
-DBOOST_SAFE_NUMBERS_BUILD_BENCHMARKS=ON \
-DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_COMPILER=gcc-14 \
${{ matrix.cmake_extra }}
cmake --build __build__ --config Release --parallel 4 \
--target benchmark_unsigned_operations benchmark_signed_operations benchmark_float_operations
- name: Run benchmarks and render results
run: |
cd ../boost-root
OUT="$GITHUB_WORKSPACE/bench-results"
mkdir -p "$OUT"
find_exe() { find __build__ -type f \( -name "$1" -o -name "$1.exe" \) | head -1; }
"$(find_exe benchmark_unsigned_operations)" $BENCH_ARGS --benchmark_out="$OUT/unsigned.json"
"$(find_exe benchmark_signed_operations)" $BENCH_ARGS --benchmark_out="$OUT/signed.json"
"$(find_exe benchmark_float_operations)" $BENCH_ARGS --benchmark_out="$OUT/float.json"
python3 "$GITHUB_WORKSPACE/test/benchmarks/render_results.py" \
--title "${{ matrix.title }}" --anchor "${{ matrix.anchor }}" --desc "${{ matrix.desc }}" \
--unsigned "$OUT/unsigned.json" --signed "$OUT/signed.json" --float "$OUT/float.json" \
> "$OUT/section.adoc"
echo "==================== ${{ matrix.title }} ===================="
cat "$OUT/section.adoc"
- name: Upload results
if: always()
uses: actions/upload-artifact@v6
with:
name: benchmarks-linux-${{ matrix.arch }}
path: bench-results
if-no-files-found: warn
macos:
name: macOS ARM64
runs-on: macos-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v6
- name: Setup Boost
run: |
LIBRARY=${GITHUB_REPOSITORY#*/}
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
cd ..
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" boost-root
cd boost-root
mkdir -p libs/$LIBRARY
# Exclude doc/: it carries an Antora examples symlink (which git-bash on
# Windows cannot recreate) and a large node_modules tree, neither of
# which the benchmark build or depinst need.
shopt -s extglob
cp -r "$GITHUB_WORKSPACE"/!(doc) libs/$LIBRARY/
git submodule update --init tools/boostdep
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" $LIBRARY
- name: Configure and build benchmarks
run: |
cd ../boost-root
cmake -S . -B __build__ \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF \
-DBOOST_INCLUDE_LIBRARIES="$LIBRARY;safe_numerics;random" \
-DBOOST_SAFE_NUMBERS_BUILD_BENCHMARKS=ON
cmake --build __build__ --config Release --parallel 4 \
--target benchmark_unsigned_operations benchmark_signed_operations benchmark_float_operations
- name: Run benchmarks and render results
run: |
cd ../boost-root
OUT="$GITHUB_WORKSPACE/bench-results"
mkdir -p "$OUT"
find_exe() { find __build__ -type f \( -name "$1" -o -name "$1.exe" \) | head -1; }
"$(find_exe benchmark_unsigned_operations)" $BENCH_ARGS --benchmark_out="$OUT/unsigned.json"
"$(find_exe benchmark_signed_operations)" $BENCH_ARGS --benchmark_out="$OUT/signed.json"
"$(find_exe benchmark_float_operations)" $BENCH_ARGS --benchmark_out="$OUT/float.json"
python3 "$GITHUB_WORKSPACE/test/benchmarks/render_results.py" \
--title "macOS ARM64" --anchor "macos_arm64" \
--desc "Run on the GitHub Actions \`macos-latest\` runner (Apple Silicon) using Apple Clang in release mode (\`-O2\`, pass:[C++]20)." \
--unsigned "$OUT/unsigned.json" --signed "$OUT/signed.json" --float "$OUT/float.json" \
> "$OUT/section.adoc"
echo "==================== macOS ARM64 ===================="
cat "$OUT/section.adoc"
- name: Upload results
if: always()
uses: actions/upload-artifact@v6
with:
name: benchmarks-macos-arm64
path: bench-results
if-no-files-found: warn
windows:
name: ${{ matrix.title }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- title: Windows x64
os: windows-latest
arch: x64
anchor: windows_x64
cmake_arch: x64
desc: "Run on the GitHub Actions `windows-latest` runner using MSVC in release mode (`/O2`, pass:[C++]20)."
- title: Windows x86 (32-bit)
os: windows-latest
arch: x86-32
anchor: windows_x86_32
cmake_arch: Win32
desc: "Run on the GitHub Actions `windows-latest` runner using MSVC targeting 32-bit x86 in release mode (`/O2`, pass:[C++]20)."
- title: Windows ARM64
os: windows-11-arm
arch: arm64
anchor: windows_arm64
cmake_arch: ARM64
desc: "Run on the GitHub Actions `windows-11-arm` runner using MSVC in release mode (`/O2`, pass:[C++]20)."
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v6
- name: Setup Boost
run: |
LIBRARY=${GITHUB_REPOSITORY#*/}
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
BOOST_BRANCH=develop && [ "$REF" = "master" ] && BOOST_BRANCH=master || true
cd ..
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" boost-root
cd boost-root
mkdir -p libs/$LIBRARY
# Exclude doc/: it carries an Antora examples symlink (which git-bash on
# Windows cannot recreate) and a large node_modules tree, neither of
# which the benchmark build or depinst need.
shopt -s extglob
cp -r "$GITHUB_WORKSPACE"/!(doc) libs/$LIBRARY/
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" $LIBRARY
- name: Configure and build benchmarks
run: |
cd ../boost-root
cmake -S . -B __build__ -A ${{ matrix.cmake_arch }} \
-DBUILD_TESTING=OFF \
-DBOOST_INCLUDE_LIBRARIES="$LIBRARY;safe_numerics;random" \
-DBOOST_SAFE_NUMBERS_BUILD_BENCHMARKS=ON
cmake --build __build__ --config Release --parallel 4 \
--target benchmark_unsigned_operations benchmark_signed_operations benchmark_float_operations
- name: Run benchmarks and render results
run: |
cd ../boost-root
OUT="$GITHUB_WORKSPACE/bench-results"
mkdir -p "$OUT"
find_exe() { find __build__ -type f \( -name "$1" -o -name "$1.exe" \) | head -1; }
"$(find_exe benchmark_unsigned_operations)" $BENCH_ARGS --benchmark_out="$OUT/unsigned.json"
"$(find_exe benchmark_signed_operations)" $BENCH_ARGS --benchmark_out="$OUT/signed.json"
"$(find_exe benchmark_float_operations)" $BENCH_ARGS --benchmark_out="$OUT/float.json"
python "$GITHUB_WORKSPACE/test/benchmarks/render_results.py" \
--title "${{ matrix.title }}" --anchor "${{ matrix.anchor }}" --desc "${{ matrix.desc }}" \
--unsigned "$OUT/unsigned.json" --signed "$OUT/signed.json" --float "$OUT/float.json" \
> "$OUT/section.adoc"
echo "==================== ${{ matrix.title }} ===================="
cat "$OUT/section.adoc"
- name: Upload results
if: always()
uses: actions/upload-artifact@v6
with:
name: benchmarks-windows-${{ matrix.arch }}
path: bench-results
if-no-files-found: warn