Commit 5f9c97a3 authored by 's avatar

Run benchmarks only when --run_benchmark is specified.


git-svn-id: https://google-glog.googlecode.com/svn/trunk@52 eb4d4688-79bd-11dd-afb4-1d65580434c0
parent c1995cd4
...@@ -92,6 +92,7 @@ static const char TEST_SRC_DIR[] = "."; ...@@ -92,6 +92,7 @@ static const char TEST_SRC_DIR[] = ".";
DEFINE_string(test_tmpdir, GetTempDir(), "Dir we use for temp files"); DEFINE_string(test_tmpdir, GetTempDir(), "Dir we use for temp files");
DEFINE_string(test_srcdir, TEST_SRC_DIR, DEFINE_string(test_srcdir, TEST_SRC_DIR,
"Source-dir root, needed to find glog_unittest_flagfile"); "Source-dir root, needed to find glog_unittest_flagfile");
DEFINE_bool(run_benchmark, false, "If true, run benchmarks");
#ifdef NDEBUG #ifdef NDEBUG
DEFINE_int32(benchmark_iters, 100000000, "Number of iterations per benchmark"); DEFINE_int32(benchmark_iters, 100000000, "Number of iterations per benchmark");
#else #else
...@@ -241,6 +242,10 @@ class BenchmarkRegisterer { ...@@ -241,6 +242,10 @@ class BenchmarkRegisterer {
}; };
static void RunSpecifiedBenchmarks() { static void RunSpecifiedBenchmarks() {
if (!FLAGS_run_benchmark) {
return;
}
int iter_cnt = FLAGS_benchmark_iters; int iter_cnt = FLAGS_benchmark_iters;
puts("Benchmark\tTime(ns)\tIterations"); puts("Benchmark\tTime(ns)\tIterations");
for (map<string, void (*)(int)>::const_iterator iter = g_benchlist.begin(); for (map<string, void (*)(int)>::const_iterator iter = g_benchlist.begin();
......
...@@ -58,6 +58,10 @@ ...@@ -58,6 +58,10 @@
DECLARE_string(log_backtrace_at); // logging.cc DECLARE_string(log_backtrace_at); // logging.cc
#ifdef HAVE_LIB_GFLAGS
#include <gflags/gflags.h>
#endif
#ifdef HAVE_LIB_GMOCK #ifdef HAVE_LIB_GMOCK
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include "mock-log.h" #include "mock-log.h"
...@@ -168,6 +172,10 @@ static void BM_vlog(int n) { ...@@ -168,6 +172,10 @@ static void BM_vlog(int n) {
BENCHMARK(BM_vlog); BENCHMARK(BM_vlog);
int main(int argc, char **argv) { int main(int argc, char **argv) {
#ifdef HAVE_LIB_GFLAGS
ParseCommandLineFlags(&argc, &argv, true);
#endif
// Test some basics before InitGoogleLogging: // Test some basics before InitGoogleLogging:
CaptureTestStderr(); CaptureTestStderr();
LogWithLevels(FLAGS_v, FLAGS_stderrthreshold, LogWithLevels(FLAGS_v, FLAGS_stderrthreshold,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment