From bee17089e6372ab11644726c5a9d4c89e40652d9 Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Thu, 13 Nov 2025 12:45:41 +0100 Subject: [PATCH] feat: accept rename instrumentation to simulation `instrumentation` is still accepted as an input, but it maps to simulation internally, as we plan to phase it out. --- core/BUILD | 9 ++++++++- core/CMakeLists.txt | 6 +++--- google_benchmark/include/benchmark/benchmark.h | 14 +++++++------- google_benchmark/src/benchmark.cc | 8 ++++---- google_benchmark/src/benchmark_api_internal.cc | 4 ++-- google_benchmark/src/benchmark_api_internal.h | 8 ++++---- google_benchmark/src/benchmark_runner.cc | 6 +++--- 7 files changed, 31 insertions(+), 24 deletions(-) diff --git a/core/BUILD b/core/BUILD index 4c91d3d..a5a13fe 100644 --- a/core/BUILD +++ b/core/BUILD @@ -81,7 +81,8 @@ cc_library( defines = [ "CODSPEED_VERSION=\\\"{}\\\"".format(CODSPEED_VERSION), ] + select({ - ":instrumentation_mode": ["CODSPEED_ENABLED", "CODSPEED_INSTRUMENTATION"], + ":instrumentation_mode": ["CODSPEED_ENABLED", "CODSPEED_SIMULATION"], + ":simulation_mode": ["CODSPEED_ENABLED", "CODSPEED_SIMULATION"], ":walltime_mode": ["CODSPEED_ENABLED", "CODSPEED_WALLTIME"], "//conditions:default": [], }), @@ -96,6 +97,7 @@ string_flag( values = [ "off", "instrumentation", + "simulation", "walltime", ], visibility = ["//visibility:public"], @@ -106,6 +108,11 @@ config_setting( flag_values = {":codspeed_mode": "instrumentation"}, ) +config_setting( + name = "simulation_mode", + flag_values = {":codspeed_mode": "simulation"}, +) + config_setting( name = "walltime_mode", flag_values = {":codspeed_mode": "walltime"}, diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 6a8c6ab..bd8a021 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -143,7 +143,7 @@ target_compile_definitions( message(STATUS "Using codspeed root directory: ${CODSPEED_ROOT_DIR}") -set(CODSPEED_MODE_ALLOWED_VALUES "off" "instrumentation" "walltime") +set(CODSPEED_MODE_ALLOWED_VALUES "off" "instrumentation" "simulation" "walltime") set(CODSPEED_MODE "off" CACHE STRING "Build mode for Codspeed") set_property( CACHE CODSPEED_MODE @@ -166,10 +166,10 @@ if(NOT CODSPEED_MODE STREQUAL "off") endif() # Define a preprocessor macro based on the build mode - if(CODSPEED_MODE STREQUAL "instrumentation") + if(CODSPEED_MODE STREQUAL "instrumentation" OR CODSPEED_MODE STREQUAL "simulation") target_compile_definitions( codspeed - PUBLIC -DCODSPEED_INSTRUMENTATION + PUBLIC -DCODSPEED_SIMULATION ) elseif(CODSPEED_MODE STREQUAL "walltime") target_compile_definitions(codspeed PUBLIC -DCODSPEED_WALLTIME) diff --git a/google_benchmark/include/benchmark/benchmark.h b/google_benchmark/include/benchmark/benchmark.h index 0e7d96d..5edffaf 100644 --- a/google_benchmark/include/benchmark/benchmark.h +++ b/google_benchmark/include/benchmark/benchmark.h @@ -946,7 +946,7 @@ class BENCHMARK_EXPORT BENCHMARK_INTERNAL_CACHELINE_ALIGNED State { public: const IterationCount max_iterations; -#if defined(CODSPEED_INSTRUMENTATION) || defined(CODSPEED_WALLTIME) +#if defined(CODSPEED_SIMULATION) || defined(CODSPEED_WALLTIME) codspeed::CodSpeed* codspeed_; #endif #ifdef CODSPEED_WALLTIME @@ -973,7 +973,7 @@ class BENCHMARK_EXPORT BENCHMARK_INTERNAL_CACHELINE_ALIGNED State { internal::ThreadTimer* timer, internal::ThreadManager* manager, internal::PerfCountersMeasurement* perf_counters_measurement, ProfilerManager* profiler_manager -#if defined(CODSPEED_INSTRUMENTATION) || defined(CODSPEED_WALLTIME) +#if defined(CODSPEED_SIMULATION) || defined(CODSPEED_WALLTIME) , codspeed::CodSpeed* codspeed = NULL #endif @@ -1071,12 +1071,12 @@ struct State::StateIterator { if (BENCHMARK_BUILTIN_EXPECT(cached_ != 0, true)) { return true; } -#ifdef CODSPEED_INSTRUMENTATION +#ifdef CODSPEED_SIMULATION measurement_stop(); #endif parent_->FinishKeepRunning(); -#ifdef CODSPEED_INSTRUMENTATION +#ifdef CODSPEED_SIMULATION if (parent_->codspeed_ != NULL) { parent_->codspeed_->end_benchmark(); } @@ -1093,14 +1093,14 @@ inline BENCHMARK_ALWAYS_INLINE State::StateIterator State::begin() { return StateIterator(this); } inline BENCHMARK_ALWAYS_INLINE State::StateIterator State::end() { -#ifdef CODSPEED_INSTRUMENTATION +#ifdef CODSPEED_SIMULATION if (this->codspeed_ != NULL) { this->codspeed_->start_benchmark(name_); } #endif - + StartKeepRunning(); -#ifdef CODSPEED_INSTRUMENTATION +#ifdef CODSPEED_SIMULATION measurement_start(); #endif return StateIterator(); diff --git a/google_benchmark/src/benchmark.cc b/google_benchmark/src/benchmark.cc index 9937e5c..bc5abcf 100644 --- a/google_benchmark/src/benchmark.cc +++ b/google_benchmark/src/benchmark.cc @@ -186,7 +186,7 @@ State::State(std::string name, IterationCount max_iters, internal::ThreadTimer* timer, internal::ThreadManager* manager, internal::PerfCountersMeasurement* perf_counters_measurement, ProfilerManager* profiler_manager -#if defined(CODSPEED_INSTRUMENTATION) || defined(CODSPEED_WALLTIME) +#if defined(CODSPEED_SIMULATION) || defined(CODSPEED_WALLTIME) , codspeed::CodSpeed* codspeed #endif @@ -194,7 +194,7 @@ State::State(std::string name, IterationCount max_iters, : total_iterations_(0), batch_leftover_(0), max_iterations(max_iters), -#if defined(CODSPEED_INSTRUMENTATION) || defined(CODSPEED_WALLTIME) +#if defined(CODSPEED_SIMULATION) || defined(CODSPEED_WALLTIME) codspeed_(codspeed), #endif #ifdef CODSPEED_WALLTIME @@ -462,8 +462,8 @@ void RunBenchmarks(const std::vector& benchmarks, #ifdef CODSPEED_ENABLED auto& Err = display_reporter->GetErrorStream(); // Determine the width of the name field using a minimum width of 10. -#ifdef CODSPEED_INSTRUMENTATION - Err << "Codspeed mode: instrumentation" << "\n"; +#ifdef CODSPEED_SIMULATION + Err << "Codspeed mode: simulation" << "\n"; #elif defined(CODSPEED_WALLTIME) Err << "Codspeed mode: walltime" << "\n"; #endif diff --git a/google_benchmark/src/benchmark_api_internal.cc b/google_benchmark/src/benchmark_api_internal.cc index a48e13f..ff12ddb 100644 --- a/google_benchmark/src/benchmark_api_internal.cc +++ b/google_benchmark/src/benchmark_api_internal.cc @@ -91,8 +91,8 @@ BenchmarkInstance::BenchmarkInstance(Benchmark* benchmark, int family_idx, teardown_ = benchmark_.teardown_; } -#ifdef CODSPEED_INSTRUMENTATION -State BenchmarkInstance::RunInstrumented( +#ifdef CODSPEED_SIMULATION +State BenchmarkInstance::RunSimulation( codspeed::CodSpeed* codspeed, internal::ThreadTimer* timer, internal::ThreadManager* manager, internal::PerfCountersMeasurement* perf_counters_measurement, diff --git a/google_benchmark/src/benchmark_api_internal.h b/google_benchmark/src/benchmark_api_internal.h index 8f702cd..c4a933f 100644 --- a/google_benchmark/src/benchmark_api_internal.h +++ b/google_benchmark/src/benchmark_api_internal.h @@ -9,7 +9,7 @@ #include #include "benchmark/benchmark.h" -#ifdef CODSPEED_INSTRUMENTATION +#ifdef CODSPEED_SIMULATION #include "codspeed.h" #endif #include "commandlineflags.h" @@ -38,7 +38,7 @@ class BenchmarkInstance { BigOFunc* complexity_lambda() const { return complexity_lambda_; } const std::vector& statistics() const { return statistics_; } int repetitions() const { -#ifdef CODSPEED_INSTRUMENTATION +#ifdef CODSPEED_SIMULATION (void)repetitions_; return 1; #else @@ -57,8 +57,8 @@ class BenchmarkInstance { internal::PerfCountersMeasurement* perf_counters_measurement, ProfilerManager* profiler_manager) const; -#ifdef CODSPEED_INSTRUMENTATION - State RunInstrumented( +#ifdef CODSPEED_SIMULATION + State RunSimulation( codspeed::CodSpeed* codspeed, internal::ThreadTimer* timer, internal::ThreadManager* manager, internal::PerfCountersMeasurement* perf_counters_measurement, diff --git a/google_benchmark/src/benchmark_runner.cc b/google_benchmark/src/benchmark_runner.cc index 75a14cb..e4e94fe 100644 --- a/google_benchmark/src/benchmark_runner.cc +++ b/google_benchmark/src/benchmark_runner.cc @@ -461,14 +461,14 @@ void BenchmarkRunner::RunProfilerManager(IterationCount profile_iterations) { } void BenchmarkRunner::DoOneRepetition() { -#ifdef CODSPEED_INSTRUMENTATION +#ifdef CODSPEED_SIMULATION std::unique_ptr manager; manager.reset(new internal::ThreadManager(b.threads())); internal::ThreadTimer timer = internal::ThreadTimer::Create(); b.Setup(); measurement_start(); - State st = b.RunInstrumented(codspeed::CodSpeed::getInstance(), &timer, - manager.get(), nullptr, nullptr); + State st = b.RunSimulation(codspeed::CodSpeed::getInstance(), &timer, + manager.get(), nullptr, nullptr); measurement_stop(); b.Teardown();