From 430e3d340684bec26e4558bbec3b869099a9bd73 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 27 Jan 2013 17:25:58 -0800 Subject: [PATCH] benchmark: number tests, allow dry-run to get test idx #, and allow passing args to only run specific tests --- benchmark/run.cpp | 74 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/benchmark/run.cpp b/benchmark/run.cpp index f32f5e8af..5c25f40c9 100644 --- a/benchmark/run.cpp +++ b/benchmark/run.cpp @@ -11,6 +11,7 @@ #include #include #include +#include // boost #include @@ -25,32 +26,51 @@ using namespace boost::chrono; using namespace mapnik; +static unsigned test_num = 1; +static bool dry_run = false; +static std::set test_set; + typedef process_cpu_clock clock_type; typedef clock_type::duration dur; template void benchmark(T test, std::string const& name) { - if (!test.validate()) throw std::runtime_error(std::string("test did not validate: ") + name); - process_cpu_clock::time_point start; - dur elapsed; - if (test.threads_ > 0) { - boost::thread_group tg; - for (unsigned i=0;i ": "") - << name << ": " - << boost::chrono::duration_cast(elapsed) << "\n"; + if (should_run_test) { + if (!test.validate()) { + std::clog << "test did not validate: " << name << "\n"; + //throw std::runtime_error(std::string("test did not validate: ") + name); + } + if (dry_run) { + std::clog << test_num << ") " << (test.threads_ ? "threaded -> ": "") + << name << "\n"; + } else { + process_cpu_clock::time_point start; + dur elapsed; + if (test.threads_ > 0) { + boost::thread_group tg; + for (unsigned i=0;i ": "") + << name << ": " + << boost::chrono::duration_cast(elapsed) << "\n"; + } + } + test_num++; } bool compare_images(std::string const& src_fn,std::string const& dest_fn) @@ -249,11 +269,25 @@ struct test5 }; -int main( int, char*[] ) +int main( int argc, char** argv) { + if (argc > 0) { + for (int i=0;i