@@ -183,6 +183,13 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond);
183183
184184#include " benchmark/export.h"
185185
186+ #ifdef CODSPEED_ENABLED
187+ #include < codspeed.h>
188+ #include < measurement.hpp>
189+
190+ #include < filesystem>
191+ #endif // CODSPEED_ENABLED
192+
186193#if defined(_MSC_VER)
187194#include < intrin.h> // for _ReadWriteBarrier
188195#endif
@@ -939,6 +946,9 @@ class BENCHMARK_EXPORT BENCHMARK_INTERNAL_CACHELINE_ALIGNED State {
939946
940947 public:
941948 const IterationCount max_iterations;
949+ #ifdef CODSPEED_INSTRUMENTATION
950+ codspeed::CodSpeed *codspeed_;
951+ #endif
942952
943953 private:
944954 bool started_;
@@ -959,7 +969,12 @@ class BENCHMARK_EXPORT BENCHMARK_INTERNAL_CACHELINE_ALIGNED State {
959969 const std::vector<int64_t >& ranges, int thread_i, int n_threads,
960970 internal::ThreadTimer* timer, internal::ThreadManager* manager,
961971 internal::PerfCountersMeasurement* perf_counters_measurement,
962- ProfilerManager* profiler_manager);
972+ ProfilerManager* profiler_manager
973+ #ifdef CODSPEED_INSTRUMENTATION
974+ ,
975+ codspeed::CodSpeed *codspeed = NULL
976+ #endif
977+ );
963978
964979 void StartKeepRunning ();
965980 // Implementation of KeepRunning() and KeepRunningBatch().
@@ -1049,6 +1064,11 @@ struct State::StateIterator {
10491064 BENCHMARK_ALWAYS_INLINE
10501065 bool operator !=(StateIterator const &) const {
10511066 if (BENCHMARK_BUILTIN_EXPECT (cached_ != 0 , true )) return true ;
1067+ #ifdef CODSPEED_INSTRUMENTATION
1068+ if (parent_->codspeed_ != NULL ) {
1069+ parent_->codspeed_ ->end_benchmark ();
1070+ }
1071+ #endif
10521072 parent_->FinishKeepRunning ();
10531073 return false ;
10541074 }
@@ -1063,6 +1083,12 @@ inline BENCHMARK_ALWAYS_INLINE State::StateIterator State::begin() {
10631083}
10641084inline BENCHMARK_ALWAYS_INLINE State::StateIterator State::end () {
10651085 StartKeepRunning ();
1086+ #ifdef CODSPEED_INSTRUMENTATION
1087+ if (this ->codspeed_ != NULL ) {
1088+ this ->codspeed_ ->start_benchmark (name_);
1089+ measurement_start ();
1090+ }
1091+ #endif
10661092 return StateIterator ();
10671093}
10681094
@@ -1439,10 +1465,6 @@ class Fixture : public internal::Benchmark {
14391465 n) [[maybe_unused]]
14401466
14411467#ifdef CODSPEED_ENABLED
1442- #include < codspeed.h>
1443-
1444- #include < filesystem>
1445-
14461468#define CUR_FILE \
14471469 codspeed::get_path_relative_to_workspace (__FILE__) + "::"
14481470#define NAMESPACE \
0 commit comments