Skip to content
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
cxx: 'g++-14'
flags: '-DENABLE_TRACING=OFF -DENABLE_LOGGING=OFF'
- os: 'ubuntu-24.04'
cc: 'clang-19'
cxx: 'clang++-19'
cc: 'clang-22'
cxx: 'clang++-22'
flags: ''
- os: 'ubuntu-24.04'
cc: 'clang-21'
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
run: |
ctest --test-dir build/plugins/simd/test --output-on-failure
- name: test inlining plugin
if: startsWith(matrix.cc, 'clang-19') || startsWith(matrix.cc, 'clang-20') || startsWith(matrix.cc, 'clang-21')
if: startsWith(matrix.cc, 'clang-20') || startsWith(matrix.cc, 'clang-21') || startsWith(matrix.cc, 'clang-22')
shell: bash
run: |
ctest --test-dir build/plugins/inlining/test --output-on-failure
Expand Down
4 changes: 2 additions & 2 deletions third_party/Catch2/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ expand_template(
"#cmakedefine CATCH_CONFIG_WINDOWS_SEH": "",
"#cmakedefine CATCH_CONFIG_USE_BUILTIN_CONSTANT_P": "",
"#cmakedefine CATCH_CONFIG_NO_USE_BUILTIN_CONSTANT_P": "",
"#cmakedefine CATCH_CONFIG_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS": "",
"#cmakedefine CATCH_CONFIG_NO_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS": "",
"#cmakedefine CATCH_CONFIG_THREAD_SAFE_ASSERTIONS": "",
"#cmakedefine CATCH_CONFIG_NO_THREAD_SAFE_ASSERTIONS": "",
},
template = "src/catch2/catch_user_config.hpp.in",
)
Expand Down
2 changes: 1 addition & 1 deletion third_party/Catch2/CMake/CatchConfigOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ set(_OverridableOptions
"EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT"
"USE_BUILTIN_CONSTANT_P"
"DEPRECATION_ANNOTATIONS"
"EXPERIMENTAL_THREAD_SAFE_ASSERTIONS"
"THREAD_SAFE_ASSERTIONS"
)

foreach(OptionName ${_OverridableOptions})
Expand Down
2 changes: 1 addition & 1 deletion third_party/Catch2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if(CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()

project(Catch2
VERSION 3.11.0 # CML version placeholder, don't delete
VERSION 3.15.1 # CML version placeholder, don't delete
LANGUAGES CXX
HOMEPAGE_URL "https://github.com/catchorg/Catch2"
DESCRIPTION "A modern, C++-native, unit test framework."
Expand Down
698 changes: 432 additions & 266 deletions third_party/Catch2/Doxyfile

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions third_party/Catch2/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module(name = "catch2")

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "rules_cc", version = "0.2.16")
bazel_dep(name = "rules_license", version = "1.0.0")
13 changes: 1 addition & 12 deletions third_party/Catch2/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
<a id="top"></a>

<table width="100%">
<tr>
<td align="center" width="50%"><img src="/data/artwork/catch2-logo-full-with-background.svg" width="100%"></td>
<td align="center" width="50%">
<figure>
<figcaption>Special thanks to:</figcaption>
<a href="https://tuple.app/catch2"><img src="/data/sponsors/github_repo_sponsorship.png" width="100%"></a>
</figure>
</td>
</tr>
</table>
![Catch2 logo](data/artwork/catch2-logo-full-with-background.svg)

[![Github Releases](https://img.shields.io/github/release/catchorg/catch2.svg)](https://github.com/catchorg/catch2/releases)
[![Linux build status](https://github.com/catchorg/Catch2/actions/workflows/linux-simple-builds.yml/badge.svg)](https://github.com/catchorg/Catch2/actions/workflows/linux-simple-builds.yml)
Expand Down
7 changes: 6 additions & 1 deletion third_party/Catch2/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ add_executable(AssertionsSlowPath
assertion_listener.cpp
)

add_executable(EmptyExecutable
only_include.cpp
)

target_link_libraries(AssertionsFastPath PRIVATE Catch2::Catch2WithMain)
target_link_libraries(AssertionsSlowPath PRIVATE Catch2::Catch2WithMain)
target_link_libraries(EmptyExecutable PRIVATE Catch2::Catch2WithMain)

list(APPEND CATCH_TEST_TARGETS AssertionsFastPath AssertionsSlowPath)
list(APPEND CATCH_TEST_TARGETS AssertionsFastPath AssertionsSlowPath EmptyExecutable)
set(CATCH_TEST_TARGETS ${CATCH_TEST_TARGETS} PARENT_SCOPE)
2 changes: 2 additions & 0 deletions third_party/Catch2/benchmarks/assertion_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/**
* Event listener that listens to all assertions, forcing assertion slow path
*/
namespace {
class AssertionSlowPathListener : public Catch::EventListenerBase {
public:
static std::string getDescription() {
Expand All @@ -26,3 +27,4 @@ class AssertionSlowPathListener : public Catch::EventListenerBase {
};

CATCH_REGISTER_LISTENER( AssertionSlowPathListener )
}
16 changes: 16 additions & 0 deletions third_party/Catch2/benchmarks/only_include.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

// Copyright Catch2 Authors
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)

// SPDX-License-Identifier: BSL-1.0

/**\file
* "empty" include of catch_test_macros.hpp
*
* This file does only one thing: include `catch2/catch_test_macros.hpp`,
* so that we can measure the compilation cost of the header.
*/

#include <catch2/catch_test_macros.hpp>
81 changes: 81 additions & 0 deletions third_party/Catch2/benchmarks/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<a id="top"></a>

# Benchmarks of Catch2

This folder holds benchmarks for Catch2. It should not be built for the
small(er) test sets, as it is only relevant for running (mainly runtime)
benchmarks.

Below you will find some practical examples using
[hyperfine](https://github.com/sharkdp/hyperfine) to determine the
performance of various scenarios. They assume two parallel checkouts, one
named `Catch2-old` and the other `Catch2-new`. You will need to change
the paths to work on your own machine.


## Runtime benchmarks

The runtime benchmarks currently consist of few different `TEST_CASE`s,
each with a simple loop over different assertion type. They are compiled
into two binaries, one for assertion slow path and one for assertion fast
path.


### Assumptions and notes about real-world usage

The basic assertion macro, `REQUIRE` (and `CHECK`) is the most common one,
by far. Thus, it is the most important one to run quickly. It is probably
followed by the matcher macro, `REQUIRE_THAT`.

The most common result of an assertion is that it passes. Even if it is
stringified and reported, that is most likely due to some listener/reporter
that wants the string representation, not because it failed.

The performance of both Debug and Release builds are important; users
will run tests in both. LTO runtime performance is not too important,
but compile time perf is.


### Examples

**Compare performance of `REQUIRE` in slow path, debug build**
```text
hyperfine --warmup 2 --shell none --parameter-list version old,new '/home/xarn/benches/Catch2-{version}/build-debug/benchmarks/AssertionsSlowPath -o /dev/null "REQUIRE"'
```

**Compare performance of `REQUIRE_THAT` in fast path, release build**
```text
hyperfine --warmup 2 --shell none --parameter-list version old,new '/home/xarn/benches/Catch2-{version}/build-release/benchmarks/AssertionsFastPath -o /dev/null "REQUIRE_THAT"'
```

**Compare performance of `REQUIRE` with stringification enabled, release build**
```text
hyperfine --warmup 2 --shell none --parameter-list version old,new '/home/xarn/benches/Catch2-{version}/build-release/benchmarks/AssertionsFastPath -s -o /dev/null "REQUIRE"'
```
_Note that we redirect the output to `/dev/null` to reduce the overhead of the actual output printing, to see just the impact of stringification._

TODO:
* Start empty binary (set up cost base)
* Start binary with X (100/1k/10k) tests (test registration cost)
* Section tracking

## Compilation benchmarks

As tests are often iterated upon and relinked, the compilation cost of
Catch2 is also important.


### Examples

**Compare overhead of including `catch_test_macros.hpp`**
```text
hyperfine --warmup 2 --shell none --parameter-list version old,new '/usr/bin/c++ -I/home/xarn/benches/Catch2-{version}/src/catch2/.. -I/home/xarn/benches/Catch2-{version}/build-debug/generated-includes -g -o /dev/null -c /home/xarn/benches/Catch2-{version}/benchmarks/only_include.cpp'
```

**Compare build time of Catch2's `SelfTest` test suite, Debug build**
```text
hyperfine --warmup 2 --parameter-list version old,vas --prepare 'find ~/benches/Catch2-{version}/tests/SelfTest -type f -name "*.cpp" -exec touch {} +' 'ninja -j 1 -C ~/benches/Catch2-{version}/build-debug'
```

TODO:
* Link-only recipe
45 changes: 36 additions & 9 deletions third_party/Catch2/benchmarks/runtime_assertion_benches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,48 @@
// SPDX-License-Identifier: BSL-1.0

#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_templated.hpp>

TEST_CASE("Simple REQUIRE - 10M") {
for (size_t i = 0; i < 10'000'000; ++i) {
REQUIRE(true);
namespace {

class MatchAllMatcher final : public Catch::Matchers::MatcherGenericBase {
public:
template <typename Any>
bool match( Any&& ) const {
return true;
}

std::string describe() const override {
using namespace std::string_literals;
return "Long string that does not fit into SSO"s;
}
};

MatchAllMatcher MatchAll() { return MatchAllMatcher(); }


TEST_CASE( "REQUIRE", "[assertions]" ) {
for ( size_t i = 0; i < 10'000'000; ++i ) {
REQUIRE( true );
}
}

TEST_CASE("Simple NOTHROW - 10M") {
for (size_t i = 0; i < 10'000'000; ++i) {
REQUIRE_NOTHROW([](){}());
TEST_CASE( "REQUIRE_THAT", "[assertions][matchers]" ) {
for ( size_t i = 0; i < 10'000'000; ++i ) {
REQUIRE_THAT( 1, MatchAll() );
}
}

TEST_CASE("Simple THROWS - 10M") {
for (size_t i = 0; i < 10'000'000; ++i) {
REQUIRE_THROWS([]() { throw 1; }());
TEST_CASE( "REQUIRE_NOTHROW", "[assertions][exceptions]" ) {
for ( size_t i = 0; i < 10'000'000; ++i ) {
REQUIRE_NOTHROW( []() {}() );
}
}

TEST_CASE( "REQUIRE_THROWS", "[assertions][exceptions]" ) {
for ( size_t i = 0; i < 10'000'000; ++i ) {
REQUIRE_THROWS( []() { throw 1; }() );
}
}

} // namespace
1 change: 1 addition & 0 deletions third_party/Catch2/extras/CatchAddTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ function(catch_discover_tests_impl)

# Exit early if no tests are detected
if(num_tests STREQUAL "0")
file(WRITE "${_CTEST_FILE}" "")
return()
endif()

Expand Down
Loading
Loading