20 #include <OptionParser.h>
26 auto parser = optparse::OptionParser().version(
version);
28 const char* output[] = {
"console",
"csv",
"json" };
30 parser.add_option(
"-f",
"--filter").dest(
"filter").help(
"Filter benchmarks by the given regexp pattern");
31 parser.add_option(
"-l",
"--list").dest(
"list").action(
"store_true").help(
"List all avaliable benchmarks");
32 parser.add_option(
"-o",
"--output").dest(
"output").choices(&output[0], &output[3]).set_default(output[0]).help(
"Output format (console, csv, json). Default: %default");
33 parser.add_option(
"-q",
"--quiet").dest(
"quiet").action(
"store_true").help(
"Launch in quiet mode. No progress will be shown!");
34 parser.add_option(
"-r",
"--histograms").dest(
"histograms").action(
"store").type(
"int").set_default(0).help(
"Create High Dynamic Range (HDR) Histogram files with a given resolution. Default: %default");
36 optparse::Values options = parser.parse_args(argc, argv);
41 parser.error(
"Console launcher double initialization!");
45 if (options.get(
"help"))
52 _list = options.get(
"list");
53 _quiet = options.get(
"quiet");
54 _histograms = (int32_t)options.get(
"histograms");
55 if (options.is_set(
"filter"))
56 _filter = options[
"filter"];
57 if (options.is_set(
"output"))
58 _output = options[
"output"];
69 std::regex matcher(_filter);
73 if (_filter.empty() || std::regex_match(benchmark->name(), matcher))
74 std::cout << benchmark->name() << std::endl;
86 if (_output ==
"console")
91 else if (_output ==
"csv")
96 else if (_output ==
"json")
const std::string & name() const
Get benchmark name.
Benchmark running context.
virtual std::string description() const
Get description of the current benchmark running context.
void onLaunched(int current, int total, const BenchmarkBase &benchmark, const Context &context, int attempt) override
Handle benchmark launched notification.
void Execute()
Execute benchmarks and show progress in console.
void Initialize(const int argc, char const *const *const argv)
Initialized console launcher.
void onLaunching(int current, int total, const BenchmarkBase &benchmark, const Context &context, int attempt) override
Handle benchmark launching notification.
void Report() const
Report benchmarks results in console.
virtual void Launch(const std::string &pattern="")
Launch registered benchmarks.
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.
Comma-separated values (CSV) reporter.
Console management definition.
Console launcher definition.
C++ Benchmark project definitions.
const char version[]
Project version.
@ LIGHTCYAN
Light cyan color.
@ DARKGREY
Dark grey color.
@ LIGHTGREEN
Light green color.
Console reporter definition.
Comma-separated values (CSV) reporter definition.
JSON reporter definition.