[kbenchmark] Add filter option (#5360)
author윤지영/On-Device Lab(SR)/Staff Engineer/삼성전자 <jy910.yun@samsung.com>
Wed, 26 Jun 2019 09:39:06 +0000 (18:39 +0900)
committer이춘석/On-Device Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Wed, 26 Jun 2019 09:39:06 +0000 (18:39 +0900)
This option allows to run benchmark whose name matches the regex.

Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
tools/kbenchmark/Args.cc
tools/kbenchmark/Args.h
tools/kbenchmark/Driver.cc

index 95145a8..204810b 100644 (file)
@@ -33,6 +33,7 @@ void Args::Initialize(const int argc, char **argv)
     ("config,c", po::value<std::string>(&_config)->required(), "Configuration filename")
     ("kernel,k", po::value<std::vector<std::string>>(&_kernel)->multitoken()->composing()->required(), "Kernel library name, support multiple kernel libraries")
     ("reporter,r", po::value<std::string>(&_reporter)->default_value("standard"), "Set reporter types(standard, html, junit, csv)")
+    ("filter,f", po::value<std::string>(&_filter)->default_value(".*"), "Only run benchmarks whose name matches the regular expression pattern")
     ("verbose,v", po::value<int>(&_verbose)->default_value(0)->implicit_value(true), "Show verbose output")
     ("output,o", po::value<std::string>(&_output)->default_value(""), "Set additional strings for output file name")
   ;
index b848f95..ff1400c 100644 (file)
@@ -34,6 +34,7 @@ public:
   const std::string &config(void) { return _config; }
   const std::vector<std::string> &kernel(void) { return _kernel; }
   const std::string &reporter(void) { return _reporter; }
+  const std::string &filter(void) { return _filter; }
   const std::string &output(void) { return _output; }
   int verbose(void) { return _verbose; }
 
@@ -44,6 +45,7 @@ private:
   std::string _config;
   std::vector<std::string> _kernel;
   std::string _reporter;
+  std::string _filter;
   std::string _output;
   int _verbose;
 };
index 8d9e6b7..006fe9e 100644 (file)
@@ -85,7 +85,10 @@ int main(int argc, char *argv[])
     std::cout << "benchmark functions list:" << std::endl;
     for (auto &&f : benchmarks)
     {
-      std::cout << "    " << f.name << std::endl;
+      if (std::regex_match(f.name, std::regex(args.filter())))
+      {
+        std::cout << "    " << f.name << std::endl;
+      }
     }
   }
 
@@ -99,6 +102,7 @@ int main(int argc, char *argv[])
   // Set noninus configuration
   nonius::configuration cfg;
   cfg.reporter = reporter;
+  cfg.filter_pattern = args.filter();
   cfg.verbose = args.verbose();
   cfg.title = test_name;
   cfg.output_file = test_name + ext;