From ea5f62f03055f8186927980aa2d834c9eb4b1210 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 16 Mar 2026 22:03:16 -1000 Subject: [PATCH] Add -DNDEBUG to benchmark builds The benchmark library warns "Library was built as DEBUG" without NDEBUG. This enables debug assertions and disables optimizations in the benchmark framework, causing instrumentation overhead to show up in profiles. --- script/cpp_benchmark.py | 1 + script/setup_codspeed_lib.py | 1 + 2 files changed, 2 insertions(+) diff --git a/script/cpp_benchmark.py b/script/cpp_benchmark.py index d479938845..7487815402 100755 --- a/script/cpp_benchmark.py +++ b/script/cpp_benchmark.py @@ -53,6 +53,7 @@ def run_benchmarks(selected_components: list[str], build_only: bool = False) -> # CODSPEED_ROOT_DIR is used to display relative file paths in reports. project_root = Path(__file__).resolve().parent.parent codspeed_flags = [ + "-DNDEBUG", "-DCODSPEED_ENABLED", "-DCODSPEED_ANALYSIS", f'-DCODSPEED_ROOT_DIR=\\"{project_root}\\"', diff --git a/script/setup_codspeed_lib.py b/script/setup_codspeed_lib.py index b34eed4816..b89f5ef780 100755 --- a/script/setup_codspeed_lib.py +++ b/script/setup_codspeed_lib.py @@ -134,6 +134,7 @@ def _write_library_json( f"-I{core_include}", f"-I{hooks_include}", # google benchmark build flags + "-DNDEBUG", "-DHAVE_STD_REGEX", "-DHAVE_STEADY_CLOCK", "-DBENCHMARK_STATIC_DEFINE",