Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/scripts/compare_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# Copyright 2026 Matt Borland
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
#
# Reports the data sets in $1 against the numbers committed under
# doc/modules/ROOT/data and appends the report to the job summary. Run it from
# the root of the library checkout.
#
# This is informational only: shared runners drift by a few percent from run to
# run, so a slower number is a prompt to look, not a build failure.

set -e

RESULTS=${1:-bench-results}

PYTHON=python3
if ! command -v python3 > /dev/null 2>&1; then
PYTHON=python
fi

"$PYTHON" doc/render_benchmarks.py --compare "$RESULTS" --summary "${GITHUB_STEP_SUMMARY:-/dev/null}"
89 changes: 89 additions & 0 deletions .github/scripts/run_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash
# Copyright 2026 Matt Borland
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
#
# Builds both benchmark drivers in release mode and runs them, leaving u128.json
# and i128.json in the --out directory. Those two files are exactly what
# doc/render_benchmarks.py consumes.
#
# Run it from the root of a Boost tree that has this library in libs/int128; the
# include path is every libs/*/include in that tree, so no b2 headers step is
# needed. The drivers always exit non-zero (the Jamfile declares them run-fail),
# so success is judged on the data set actually being written.
#
# .github/scripts/run_benchmarks.sh --compiler g++-14 --out /tmp/results
# .github/scripts/run_benchmarks.sh --msvc --elements 5000000 --out C:/results

set -e

COMPILER=""
EXTRA_CXXFLAGS=""
EXTRA_LDFLAGS=""
ELEMENTS=20000000
REPETITIONS=5
OUT=""
MSVC=0

while [ $# -gt 0 ]; do
case "$1" in
--compiler) COMPILER="$2"; shift 2 ;;
--cxxflags) EXTRA_CXXFLAGS="$2"; shift 2 ;;
--ldflags) EXTRA_LDFLAGS="$2"; shift 2 ;;
--elements) ELEMENTS="$2"; shift 2 ;;
--repetitions) REPETITIONS="$2"; shift 2 ;;
--out) OUT="$2"; shift 2 ;;
--msvc) MSVC=1; shift ;;
*) echo "unknown argument: $1" >&2; exit 2 ;;
esac
done

if [ -z "$OUT" ]; then
echo "error: --out is required" >&2
exit 2
fi

if [ ! -d libs/int128/test ]; then
echo "error: run this from the root of a Boost tree holding libs/int128" >&2
exit 2
fi

mkdir -p "$OUT"

# Every dependency is header only from the benchmarks' point of view, so the
# include path is simply all of the libraries checked out in this tree.
INCLUDES=""
for dir in libs/*/include libs/*/*/include; do
if [ -d "$dir" ]; then
INCLUDES="$INCLUDES -I$dir"
fi
done

for sign in u128 i128; do
source_file="libs/int128/test/benchmark_$sign.cpp"

if [ "$MSVC" = 1 ]; then
# LARGEADDRESSAWARE lets the 32-bit build address more than 2GB, which
# the widest vectors need.
executable="./benchmark_$sign.exe"
# shellcheck disable=SC2086
cl -nologo -std:c++20 -O2 -EHsc -DNDEBUG $INCLUDES "$source_file" \
-Fe:"benchmark_$sign.exe" -link -LARGEADDRESSAWARE
else
executable="./benchmark_$sign"
# shellcheck disable=SC2086
$COMPILER -std=c++20 -O2 -DNDEBUG $EXTRA_CXXFLAGS $INCLUDES "$source_file" \
-o "benchmark_$sign" $EXTRA_LDFLAGS
fi

echo "==================== benchmark_$sign ===================="
"$executable" --elements "$ELEMENTS" --repetitions "$REPETITIONS" --json "$OUT/$sign.json" || true

if [ ! -s "$OUT/$sign.json" ]; then
echo "error: benchmark_$sign did not write $OUT/$sign.json" >&2
exit 1
fi
done

echo "==================== data sets ===================="
ls -l "$OUT"
42 changes: 42 additions & 0 deletions .github/scripts/setup_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
# Copyright 2026 Matt Borland
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
#
# Clones a Boost tree next to the checkout, drops this library into it, and
# installs the dependencies the benchmarks need. Exports BOOST_ROOT for the
# steps that follow. Only used by .github/workflows/benchmarks.yml.

set -e

LIBRARY=${GITHUB_REPOSITORY#*/}
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}

BOOST_BRANCH=develop
if [ "$REF" = "master" ]; then
BOOST_BRANCH=master
fi

PYTHON=python3
if ! command -v python3 > /dev/null 2>&1; then
PYTHON=python
fi

cd ..
git clone -b "$BOOST_BRANCH" --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
mkdir -p "libs/$LIBRARY"

# Everything except doc/: it carries an Antora examples symlink that git-bash on
# Windows cannot recreate, plus a node_modules tree that nothing here needs.
for entry in "$GITHUB_WORKSPACE"/*; do
if [ "$(basename "$entry")" != doc ]; then
cp -r "$entry" "libs/$LIBRARY/"
fi
done

git submodule update --init tools/boostdep
"$PYTHON" tools/boostdep/depinst/depinst.py --git_args "--jobs ${GIT_FETCH_JOBS:-4}" "$LIBRARY"

echo "BOOST_ROOT=$(pwd)" >> "$GITHUB_ENV"
Loading
Loading