diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index 58a8a302..b25b0010 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -291,8 +291,10 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond); namespace benchmark { class BenchmarkReporter; +BENCHMARK_EXPORT void PrintDefaultHelp(); + BENCHMARK_EXPORT void Initialize(int* argc, char** argv, - void (*HelperPrinterf)() = NULL); + void (*HelperPrinterf)() = PrintDefaultHelp); BENCHMARK_EXPORT void Shutdown(); // Report to stdout all arguments in 'argv' as unrecognized except the first. diff --git a/src/benchmark.cc b/src/benchmark.cc index 254b95ef..88167f69 100644 --- a/src/benchmark.cc +++ b/src/benchmark.cc @@ -567,28 +567,7 @@ namespace internal { void (*HelperPrintf)(); void PrintUsageAndExit() { - if (HelperPrintf) { - HelperPrintf(); - } else { - fprintf(stdout, - "benchmark" - " [--benchmark_list_tests={true|false}]\n" - " [--benchmark_filter=]\n" - " [--benchmark_min_time=]\n" - " [--benchmark_min_warmup_time=]\n" - " [--benchmark_repetitions=]\n" - " [--benchmark_enable_random_interleaving={true|false}]\n" - " [--benchmark_report_aggregates_only={true|false}]\n" - " [--benchmark_display_aggregates_only={true|false}]\n" - " [--benchmark_format=]\n" - " [--benchmark_out=]\n" - " [--benchmark_out_format=]\n" - " [--benchmark_color={auto|true|false}]\n" - " [--benchmark_counters_tabular={true|false}]\n" - " [--benchmark_context==,...]\n" - " [--benchmark_time_unit={ns|us|ms|s}]\n" - " [--v=]\n"); - } + HelperPrintf(); exit(0); } @@ -670,6 +649,27 @@ int InitializeStreams() { } // end namespace internal +void PrintDefaultHelp() { + fprintf(stdout, + "benchmark" + " [--benchmark_list_tests={true|false}]\n" + " [--benchmark_filter=]\n" + " [--benchmark_min_time=]\n" + " [--benchmark_min_warmup_time=]\n" + " [--benchmark_repetitions=]\n" + " [--benchmark_enable_random_interleaving={true|false}]\n" + " [--benchmark_report_aggregates_only={true|false}]\n" + " [--benchmark_display_aggregates_only={true|false}]\n" + " [--benchmark_format=]\n" + " [--benchmark_out=]\n" + " [--benchmark_out_format=]\n" + " [--benchmark_color={auto|true|false}]\n" + " [--benchmark_counters_tabular={true|false}]\n" + " [--benchmark_context==,...]\n" + " [--benchmark_time_unit={ns|us|ms|s}]\n" + " [--v=]\n"); +} + void Initialize(int* argc, char** argv, void (*HelperPrintf)()) { internal::ParseCommandLineFlags(argc, argv); internal::LogLevel() = FLAGS_v;