18 std::shared_ptr<PhaseCore> result;
21 auto it = std::find_if(
_phases.begin(),
_phases.end(), [&
name] (
const std::shared_ptr<PhaseCore>& item) { return item->name() == name; });
24 result = std::make_shared<PhaseCore>(
name);
32 context.
_metrics = &result->current();
37 for (
const auto& phase : phases)
43 for (
const auto& child : phase.
_child)
52 for (
auto it = phases.begin(); it != phases.end(); ++it)
54 for (
auto next = it + 1; next != phases.end(); ++next)
56 if ((*it)->name() == (*next)->name())
59 (*it)->MergeMetrics(**next);
62 (*it)->_child.insert((*it)->_child.end(), (*next)->_child.begin(), (*next)->_child.end());
71 phases.erase(std::remove_if(phases.begin(), phases.end(), [](
const std::shared_ptr<PhaseCore>& p) { return p->_thread == 0; }), phases.end());
74 for (
const auto& phase : phases)
80 for (
const auto& phase : phases)
86 for (
const auto& child : phase.
_child)
93 for (
const auto& phase : phases)
100 for (
const auto& child : phase.
_child)
Benchmark base definition.
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 UpdateBenchmarkThreads(std::vector< std::shared_ptr< PhaseCore >> &phases)
Update benchmark threads metrics for the given benchmark phases collection.
const std::string & name() const
Get benchmark name.
std::string _name
Benchmark name.
static void UpdateBenchmarkOperations(std::vector< std::shared_ptr< PhaseCore >> &phases)
Update benchmark operations for the given benchmark phases collection.
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.
Benchmark running context.
PhaseCore * _current
Current benchmark phase.
virtual std::string description() const
Get description of the current benchmark running context.
PhaseMetrics * _metrics
Current benchmark metrics.
void ResetMetrics() noexcept
Reset current phase metrics.
PhaseMetrics _metrics_result
Result phase metrics.
std::string _name
Phase name.
std::vector< std::shared_ptr< PhaseCore > > _child
Child phases container.
void MergeMetrics()
Merge phase metrics (current to result)
void AddOperations(int64_t operations) noexcept
Increase operations count of the current phase.
C++ Benchmark project definitions.