|
2 | 2 |
|
3 | 3 | #include <cinttypes>
|
4 | 4 |
|
| 5 | +#include "codspeed.h" |
5 | 6 | #include "string_util.h"
|
| 7 | +#include "thread_timer.h" |
6 | 8 |
|
7 | 9 | namespace benchmark {
|
8 | 10 | namespace internal {
|
@@ -89,6 +91,28 @@ BenchmarkInstance::BenchmarkInstance(Benchmark* benchmark, int family_idx,
|
89 | 91 | teardown_ = benchmark_.teardown_;
|
90 | 92 | }
|
91 | 93 |
|
| 94 | +#ifdef CODSPEED_INSTRUMENTATION |
| 95 | +State BenchmarkInstance::RunInstrumented( |
| 96 | + CodSpeed* codspeed, internal::ThreadTimer* timer, |
| 97 | + internal::ThreadManager* manager, |
| 98 | + internal::PerfCountersMeasurement* perf_counters_measurement, |
| 99 | + ProfilerManager* profiler_manager) const { |
| 100 | + State st(name_.function_name, 1, args_, 0, 1, timer, manager, |
| 101 | + perf_counters_measurement, profiler_manager); |
| 102 | + // Do one repetition to avoid flakiness due to inconcistencies in CPU cache |
| 103 | + // from execution order |
| 104 | + |
| 105 | + internal::ThreadTimer warmup_timer = internal::ThreadTimer::Create(); |
| 106 | + State warmup_state(name_.function_name, 1, args_, 0, 1, &warmup_timer, |
| 107 | + manager, perf_counters_measurement, profiler_manager); |
| 108 | + benchmark_.Run(warmup_state); |
| 109 | + codspeed->start_benchmark(name().str()); |
| 110 | + benchmark_.Run(st); |
| 111 | + codspeed->end_benchmark(); |
| 112 | + return st; |
| 113 | +} |
| 114 | +#endif |
| 115 | + |
92 | 116 | State BenchmarkInstance::Run(
|
93 | 117 | IterationCount iters, int thread_id, internal::ThreadTimer* timer,
|
94 | 118 | internal::ThreadManager* manager,
|
|
0 commit comments