20void Benchmark::Launch(
int& current,
int total,
LauncherHandler& handler)
23 for (
int attempt = 1; attempt <=
_settings.attempts(); ++attempt)
27 _settings._params.emplace_back(-1, -1, -1);
30 for (
const auto& param :
_settings.params())
33 Context context(std::get<0>(param), std::get<1>(param), std::get<2>(param));
39 std::tuple<int64_t, int64_t, int> latency_params(
_settings.latency());
40 bool latency_auto =
_settings.latency_auto();
41 context._current->InitLatencyHistogram(latency_params);
44 handler.onLaunching(++current, total, *
this, context, attempt);
51 int64_t operations =
_settings.operations();
53 uint64_t timestamp = 0;
59 uint64_t timespan = 0;
62 for (; timespan < 1000000000; ++count)
73 operations = (1000000000ull * count * duration) / timespan;
76 context._current->StartCollectingMetrics();
77 while (!context.canceled() && (infinite || (operations > 0)))
80 context._metrics->AddOperations(1);
96 context._current->StopCollectingMetrics();
102 handler.onLaunched(current, total, *
this, context, attempt);
static void UpdateBenchmarkThreads(std::vector< std::shared_ptr< PhaseCore > > &phases)
Update benchmark threads metrics for the given benchmark phases collection.
bool _launched
Benchmark launched flag.
virtual int CountLaunches() const
Get the count of benchmark launches.
Settings _settings
Benchmark settings.
static void UpdateBenchmarkNames(std::vector< std::shared_ptr< PhaseCore > > &phases)
Update benchmark names for the given benchmark phases collection.
void InitBenchmarkContext(Context &context)
Initialize benchmark context.
static void UpdateBenchmarkMetrics(std::vector< std::shared_ptr< PhaseCore > > &phases)
Update benchmark metrics for the given benchmark phases collection.
std::vector< std::shared_ptr< PhaseCore > > _phases
Benchmark phases.
virtual void Run(Context &context)=0
Benchmark run method.
virtual void Initialize(Context &context)
Initialize benchmark.
virtual void Cleanup(Context &context)
Cleanup benchmark.
static uint64_t Timestamp()
Get the current timestamp in nanoseconds.
Launcher handler definition.
C++ Benchmark project definitions.