Repository: google/benchmark
File: include/benchmark/benchmark.h (C/C++)

Code before:
#else
#define BENCHMARK_OVERRIDE
#endif

#if defined(_MSC_VER)
#pragma warning(push)
// C4251: <symbol> needs to have dll-interface to be used by clients of class
#pragma warning(disable : 4251)
#endif

namespace benchmark {
class BenchmarkReporter;

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.
// Returns true there is at least on unrecognized argument (i.e. 'argc' > 1).
BENCHMARK_EXPORT bool ReportUnrecognizedArguments(int argc, char** argv);

// Returns the current value of --benchmark_filter.
BENCHMARK_EXPORT std::string GetBenchmarkFilter();

// Sets the value of --benchmark_filter. (This will override this flag's
// current value).
BENCHMARK_EXPORT void SetBenchmarkFilter(std::string value);

// Creates a default display reporter. Used by the library when no display
// reporter is provided, but also made available for external use in case a
// custom reporter should respect the `--benchmark_format` flag as a fallback
BENCHMARK_EXPORT BenchmarkReporter* CreateDefaultDisplayReporter();

// Generate a list of benchmarks matching the specified --benchmark_filter flag
// and if --benchmark_list_tests is specified return after printing the name
// of each matching benchmark. Otherwise run each matching benchmark and
// report the results.
//
// spec : Specify the benchmarks to run. If users do not specify this arg,
//        then the value of FLAGS_benchmark_filter
//        will be used.
//
// The second and third overload use the specified 'display_reporter' and
//  'file_reporter' respectively. 'file_reporter' will write to the file
//  specified
//   by '--benchmark_output'. If '--benchmark_output' is not given the
//  'file_reporter' is ignored.
//
// RETURNS: The number of matching benchmarks.
BENCHMARK_EXPORT size_t RunSpecifiedBenchmarks();
BENCHMARK_EXPORT size_t RunSpecifiedBenchmarks(std::string spec);

Review comment (suggestion):
maybe add a note that `Initialize` will overwrite this value from the command line so it should be called _after_ `Initialize`.

Code after:
#else
#define BENCHMARK_OVERRIDE
#endif

#if defined(_MSC_VER)
#pragma warning(push)
// C4251: <symbol> needs to have dll-interface to be used by clients of class
#pragma warning(disable : 4251)
#endif

namespace benchmark {
class BenchmarkReporter;

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.
// Returns true there is at least on unrecognized argument (i.e. 'argc' > 1).
BENCHMARK_EXPORT bool ReportUnrecognizedArguments(int argc, char** argv);

// Returns the current value of --benchmark_filter.
BENCHMARK_EXPORT std::string GetBenchmarkFilter();

// Sets a new value to --benchmark_filter. (This will override this flag's
// current value).
// Should be called after `benchmark::Initialize()`, as
// `benchmark::Initialize()` will override the flag's value.
BENCHMARK_EXPORT void SetBenchmarkFilter(std::string value);

// Creates a default display reporter. Used by the library when no display
// reporter is provided, but also made available for external use in case a
// custom reporter should respect the `--benchmark_format` flag as a fallback
BENCHMARK_EXPORT BenchmarkReporter* CreateDefaultDisplayReporter();

// Generate a list of benchmarks matching the specified --benchmark_filter flag
// and if --benchmark_list_tests is specified return after printing the name
// of each matching benchmark. Otherwise run each matching benchmark and
// report the results.
//
// spec : Specify the benchmarks to run. If users do not specify this arg,
//        then the value of FLAGS_benchmark_filter
//        will be used.
//
// The second and third overload use the specified 'display_reporter' and
//  'file_reporter' respectively. 'file_reporter' will write to the file
//  specified
//   by '--benchmark_output'. If '--benchmark_output' is not given the
//  'file_reporter' is ignored.
//
// RETURNS: The number of matching benchmarks.