mirror of
https://github.com/google/benchmark.git
synced 2024-12-27 13:00:36 +08:00
Introduce the possibility to customize the help printer function (#1342)
* introduce the possibility to customize the help printer function Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> * fixed naming convertion, and introduce the option function in the init method Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> * remove the macros to inject the helper function Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> * remove the default implementation, and introduce the nullprt Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
parent
28b210ebb8
commit
c563644040
@ -291,7 +291,8 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond);
|
||||
namespace benchmark {
|
||||
class BenchmarkReporter;
|
||||
|
||||
BENCHMARK_EXPORT void Initialize(int* argc, char** argv);
|
||||
BENCHMARK_EXPORT void Initialize(int* argc, char** argv,
|
||||
void (*HelperPrinterf)() = NULL);
|
||||
BENCHMARK_EXPORT void Shutdown();
|
||||
|
||||
// Report to stdout all arguments in 'argv' as unrecognized except the first.
|
||||
@ -1202,7 +1203,6 @@ class LambdaBenchmark : public Benchmark {
|
||||
Lambda lambda_;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace internal
|
||||
|
||||
inline internal::Benchmark* RegisterBenchmark(const char* name,
|
||||
@ -1254,7 +1254,6 @@ class Fixture : public internal::Benchmark {
|
||||
protected:
|
||||
virtual void BenchmarkCase(State&) = 0;
|
||||
};
|
||||
|
||||
} // namespace benchmark
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
@ -538,24 +538,29 @@ void AddCustomContext(const std::string& key, const std::string& value) {
|
||||
|
||||
namespace internal {
|
||||
|
||||
void (*HelperPrintf)();
|
||||
|
||||
void PrintUsageAndExit() {
|
||||
fprintf(stdout,
|
||||
"benchmark"
|
||||
" [--benchmark_list_tests={true|false}]\n"
|
||||
" [--benchmark_filter=<regex>]\n"
|
||||
" [--benchmark_min_time=<min_time>]\n"
|
||||
" [--benchmark_repetitions=<num_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=<console|json|csv>]\n"
|
||||
" [--benchmark_out=<filename>]\n"
|
||||
" [--benchmark_out_format=<json|console|csv>]\n"
|
||||
" [--benchmark_color={auto|true|false}]\n"
|
||||
" [--benchmark_counters_tabular={true|false}]\n"
|
||||
" [--benchmark_perf_counters=<counter>,...]\n"
|
||||
" [--benchmark_context=<key>=<value>,...]\n"
|
||||
" [--v=<verbosity>]\n");
|
||||
if (HelperPrintf) {
|
||||
HelperPrintf();
|
||||
} else {
|
||||
fprintf(stdout,
|
||||
"benchmark"
|
||||
" [--benchmark_list_tests={true|false}]\n"
|
||||
" [--benchmark_filter=<regex>]\n"
|
||||
" [--benchmark_min_time=<min_time>]\n"
|
||||
" [--benchmark_repetitions=<num_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=<console|json|csv>]\n"
|
||||
" [--benchmark_out=<filename>]\n"
|
||||
" [--benchmark_out_format=<json|console|csv>]\n"
|
||||
" [--benchmark_color={auto|true|false}]\n"
|
||||
" [--benchmark_counters_tabular={true|false}]\n"
|
||||
" [--benchmark_context=<key>=<value>,...]\n"
|
||||
" [--v=<verbosity>]\n");
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@ -618,9 +623,10 @@ int InitializeStreams() {
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
void Initialize(int* argc, char** argv) {
|
||||
void Initialize(int* argc, char** argv, void (*HelperPrintf)()) {
|
||||
internal::ParseCommandLineFlags(argc, argv);
|
||||
internal::LogLevel() = FLAGS_v;
|
||||
internal::HelperPrintf = HelperPrintf;
|
||||
}
|
||||
|
||||
void Shutdown() { delete internal::global_context; }
|
||||
|
Loading…
Reference in New Issue
Block a user