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
35 changes: 35 additions & 0 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CodSpeed Benchmarks

on:
push:
branches:
- "main"
paths-ignore:
- '**.md'
- 'docs/**'
pull_request:
# `workflow_dispatch` allows CodSpeed to trigger backtest
# performance analysis in order to generate initial data.
workflow_dispatch:

permissions:
contents: read

jobs:
benchmarks:
name: Run benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
- name: Build the benchmark target(s)
run: |
cmake -DCMAKE_BUILD_TYPE=Release -DADA_TESTING=OFF -DADA_DEVELOPMENT_CHECKS=OFF -DADA_USE_UNSAFE_STD_REGEX_PROVIDER=ON -DADA_BENCHMARKS=ON -DCODSPEED_MODE=simulation -G Ninja -B build
cmake --build build -j
env:
CXX: g++-12
- name: Run the benchmarks
uses: CodSpeedHQ/action@v4
with:
mode: simulation
run: cmake --build build --target run_all_benchmarks

33 changes: 23 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,28 @@ if(ADA_TESTING OR ADA_BENCHMARKS OR ADA_TOOLS)
endif()
# We use Google Benchmark, but it does not build under several 32-bit systems.
if(ADA_BENCHMARKS AND (CMAKE_SIZEOF_VOID_P EQUAL 8))
CPMAddPackage(
NAME benchmark
GITHUB_REPOSITORY google/benchmark
VERSION 1.9.0
OPTIONS "BENCHMARK_ENABLE_TESTING OFF"
"BENCHMARK_ENABLE_INSTALL OFF"
"BENCHMARK_ENABLE_WERROR OFF"

)
if(DEFINED CODSPEED_MODE)
message(STATUS "Using CodSpeed-instrumented Google Benchmark")
CPMAddPackage(
NAME benchmark
GITHUB_REPOSITORY CodSpeedHQ/codspeed-cpp
VERSION 2.0.0
SOURCE_SUBDIR google_benchmark
OPTIONS "BENCHMARK_ENABLE_TESTING OFF"
"BENCHMARK_ENABLE_INSTALL OFF"
"BENCHMARK_ENABLE_WERROR OFF"
)
else()
message(STATUS "Using standard Google Benchmark")
CPMAddPackage(
NAME benchmark
GITHUB_REPOSITORY google/benchmark
VERSION 1.9.0
OPTIONS "BENCHMARK_ENABLE_TESTING OFF"
"BENCHMARK_ENABLE_INSTALL OFF"
"BENCHMARK_ENABLE_WERROR OFF"
)
endif()
endif()

if (ADA_TESTING AND NOT EMSCRIPTEN)
Expand Down Expand Up @@ -90,7 +103,7 @@ endif()

add_library(ada::ada ALIAS ada)

if(ADA_TESTING)
if(ADA_TESTING OR ADA_USE_UNSAFE_STD_REGEX_PROVIDER)
# IMPORTANT!
#
# We enable std_regex_provider for testing purposes
Expand Down
15 changes: 15 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ target_link_libraries(percent_encode PRIVATE benchmark::benchmark)
target_link_libraries(bench_search_params PRIVATE benchmark::benchmark)
target_link_libraries(urlpattern PRIVATE benchmark::benchmark)

set(BENCHMARKS wpt_bench bench benchdata bbc_bench percent_encode bench_search_params urlpattern)

add_custom_target(run_all_benchmarks
COMMAND ${CMAKE_COMMAND} -E echo "Running all benchmarks..."
)
foreach(benchmark IN LISTS BENCHMARKS)
add_custom_command(
TARGET run_all_benchmarks
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Running ${benchmark}..."
COMMAND $<TARGET_FILE:${benchmark}> --benchmark_min_time=1s
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endforeach()

option(ADA_COMPETITION "Whether to install various competitors." OFF)

# We only build url_whatwg if ICU is found, so we need to make
Expand Down
Loading