diff --git a/src/googletest.h b/src/googletest.h index abc825b..183c56b 100644 --- a/src/googletest.h +++ b/src/googletest.h @@ -92,6 +92,7 @@ static const char TEST_SRC_DIR[] = "."; DEFINE_string(test_tmpdir, GetTempDir(), "Dir we use for temp files"); DEFINE_string(test_srcdir, TEST_SRC_DIR, "Source-dir root, needed to find glog_unittest_flagfile"); +DEFINE_bool(run_benchmark, false, "If true, run benchmarks"); #ifdef NDEBUG DEFINE_int32(benchmark_iters, 100000000, "Number of iterations per benchmark"); #else @@ -241,6 +242,10 @@ class BenchmarkRegisterer { }; static void RunSpecifiedBenchmarks() { + if (!FLAGS_run_benchmark) { + return; + } + int iter_cnt = FLAGS_benchmark_iters; puts("Benchmark\tTime(ns)\tIterations"); for (map::const_iterator iter = g_benchlist.begin(); diff --git a/src/logging_unittest.cc b/src/logging_unittest.cc index c915bb8..0e25478 100644 --- a/src/logging_unittest.cc +++ b/src/logging_unittest.cc @@ -58,6 +58,10 @@ DECLARE_string(log_backtrace_at); // logging.cc +#ifdef HAVE_LIB_GFLAGS +#include +#endif + #ifdef HAVE_LIB_GMOCK #include #include "mock-log.h" @@ -168,6 +172,10 @@ static void BM_vlog(int n) { BENCHMARK(BM_vlog); int main(int argc, char **argv) { +#ifdef HAVE_LIB_GFLAGS + ParseCommandLineFlags(&argc, &argv, true); +#endif + // Test some basics before InitGoogleLogging: CaptureTestStderr(); LogWithLevels(FLAGS_v, FLAGS_stderrthreshold,