20 std::vector<std::shared_ptr<BenchmarkBase>> benchmarks;
27 std::regex matcher(pattern);
31 if (pattern.empty() || std::regex_match(benchmark->name(), matcher))
33 total += benchmark->CountLaunches();
34 benchmarks.push_back(benchmark);
39 for (
const auto& benchmark : benchmarks)
40 benchmark->Launch(current, total, *
this);
55 if (benchmark->_launched)
61 for (
const auto& root_phase : benchmark->_phases)
62 ReportPhase(reporter, *root_phase, root_phase->name());
73 void Launcher::ReportPhase(
Reporter& reporter,
const PhaseCore& phase,
const std::string& name)
const
78 for (
const auto& child : phase.
_child)
80 std::string child_name = name +
"." + child->name();
81 ReportPhase(reporter, *child, child_name);
91 if (benchmark->_launched)
94 for (
const auto& root_phase : benchmark->_phases)
95 ReportPhaseHistograms(resolution, *root_phase, root_phase->name());
100 void Launcher::ReportPhaseHistograms(int32_t resolution,
const PhaseCore& phase,
const std::string& name)
const
102 ReportPhaseHistogram(resolution, phase, name);
103 for (
const auto& child : phase.
_child)
105 std::string child_name = name +
"." + child->name();
106 ReportPhaseHistograms(resolution, *child, child_name);
110 void Launcher::ReportPhaseHistogram(int32_t resolution,
const PhaseCore& phase,
const std::string& name)
const
112 if (phase.metrics().latency())
114 const char deprecated[] =
"\\/?%*:|\"<>";
117 std::string filename(name +
".hdr");
118 for (
auto ch : filename)
119 if ((ch !=
'\\') && (ch !=
'/') && (std::find(deprecated, deprecated +
sizeof(deprecated), ch) != (deprecated +
sizeof(deprecated))))
123 FILE* file = fopen(filename.c_str(),
"w");
127 phase.PrintLatencyHistogram(file, resolution);
virtual void Launch(const std::string &pattern="")
Launch registered benchmarks.
std::vector< std::function< std::shared_ptr< BenchmarkBase >)> > _builders
Benchmark builders collection.
void Report(Reporter &reporter) const
Report benchmarks results using the given reporter.
void ReportHistograms(int32_t resolution) const
Report benchmarks High Dynamic Range (HDR) Histograms.
std::vector< std::shared_ptr< BenchmarkBase > > _benchmarks
Registered benchmarks collection.
void AddBenchmark(const std::shared_ptr< BenchmarkBase > &benchmark)
Add the given benchmark to the benchmarks collection.
const PhaseMetrics & metrics() const noexcept override
Get phase metrics.
std::vector< std::shared_ptr< PhaseCore > > _child
Child phases container.
virtual void ReportBenchmarksFooter()
Report all benchmarks footer.
virtual void ReportPhase(const PhaseCore &phase, const PhaseMetrics &metrics)=0
Report current phase information.
virtual void ReportPhaseHeader()
Report current phase header.
virtual void ReportBenchmarkHeader()
Report current benchmark header.
virtual void ReportEnvironment()
Report environment information.
virtual void ReportHeader()
Report header.
virtual void ReportFooter()
Report footer.
virtual void ReportPhasesFooter()
Report all phases footer.
virtual void ReportBenchmarkFooter()
Report current benchmark footer.
virtual void ReportBenchmark(const BenchmarkBase &benchmark, const Settings &settings)
Report current benchmark information.
virtual void ReportBenchmarksHeader()
Report all benchmarks header.
virtual void ReportPhaseFooter()
Report current phase footer.
virtual void ReportPhasesHeader()
Report all phases header.
virtual void ReportSystem()
Report system information.
Launcher base definition.
C++ Benchmark project definitions.