Merge remote-tracking branch 'origin/2.4' into merge-2.4
[profile/ivi/opencv.git] / modules / ts / src / ts_perf.cpp
index 3bcb5c1..d1c03cc 100644 (file)
@@ -1,7 +1,7 @@
 #include "precomp.hpp"
 
 #ifdef HAVE_CUDA
-#include "opencv2/core/gpumat.hpp"
+#include "opencv2/core/cuda.hpp"
 #endif
 
 #ifdef ANDROID
@@ -640,44 +640,43 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
     available_impls = availableImpls;
 
     const std::string command_line_keys =
-        "{   |perf_max_outliers           |8        |percent of allowed outliers}"
-        "{   |perf_min_samples            |10       |minimal required numer of samples}"
-        "{   |perf_force_samples          |100      |force set maximum number of samples for all tests}"
-        "{   |perf_seed                   |809564   |seed for random numbers generator}"
-        "{   |perf_threads                |-1       |the number of worker threads, if parallel execution is enabled}"
-        "{   |perf_write_sanity           |false    |create new records for sanity checks}"
-        "{   |perf_verify_sanity          |false    |fail tests having no regression data for sanity checks}"
-        "{   |perf_impl                   |" + available_impls[0] +
-                                                   "|the implementation variant of functions under test}"
-        "{   |perf_list_impls             |false    |list available implementation variants and exit}"
-        "{   |perf_run_cpu                |false    |deprecated, equivalent to --perf_impl=plain}"
-        "{   |perf_strategy               |default  |specifies performance measuring strategy: default, base or simple (weak restrictions)}"
+        "{   perf_max_outliers           |8        |percent of allowed outliers}"
+        "{   perf_min_samples            |10       |minimal required numer of samples}"
+        "{   perf_force_samples          |100      |force set maximum number of samples for all tests}"
+        "{   perf_seed                   |809564   |seed for random numbers generator}"
+        "{   perf_threads                |-1       |the number of worker threads, if parallel execution is enabled}"
+        "{   perf_write_sanity           |false    |create new records for sanity checks}"
+        "{   perf_verify_sanity          |false    |fail tests having no regression data for sanity checks}"
+        "{   perf_impl                   |" + available_impls[0] +
+                                                  "|the implementation variant of functions under test}"
+        "{   perf_list_impls             |false    |list available implementation variants and exit}"
+        "{   perf_run_cpu                |false    |deprecated, equivalent to --perf_impl=plain}"
+        "{   perf_strategy               |default  |specifies performance measuring strategy: default, base or simple (weak restrictions)}"
 #ifdef ANDROID
-        "{   |perf_time_limit             |6.0      |default time limit for a single test (in seconds)}"
-        "{   |perf_affinity_mask          |0        |set affinity mask for the main thread}"
-        "{   |perf_log_power_checkpoints  |         |additional xml logging for power measurement}"
+        "{   perf_time_limit             |6.0      |default time limit for a single test (in seconds)}"
+        "{   perf_affinity_mask          |0        |set affinity mask for the main thread}"
+        "{   perf_log_power_checkpoints  |         |additional xml logging for power measurement}"
 #else
-        "{   |perf_time_limit             |3.0      |default time limit for a single test (in seconds)}"
+        "{   perf_time_limit             |3.0      |default time limit for a single test (in seconds)}"
 #endif
-        "{   |perf_max_deviation          |1.0      |}"
-        "{h  |help                        |false    |print help info}"
+        "{   perf_max_deviation          |1.0      |}"
+        "{   help h                      |false    |print help info}"
 #ifdef HAVE_CUDA
-        "{   |perf_cuda_device            |0        |run GPU test suite onto specific CUDA capable device}"
-        "{   |perf_cuda_info_only         |false    |print an information about system and an available CUDA devices and then exit.}"
+        "{   perf_cuda_device            |0        |run CUDA test suite onto specific CUDA capable device}"
+        "{   perf_cuda_info_only         |false    |print an information about system and an available CUDA devices and then exit.}"
 #endif
     ;
 
-    cv::CommandLineParser args(argc, argv, command_line_keys.c_str());
-    if (args.get<bool>("help"))
+    cv::CommandLineParser args(argc, argv, command_line_keys);
+    if (args.has("help"))
     {
-        args.printParams();
-        printf("\n\n");
+        args.printMessage();
         return;
     }
 
     ::testing::AddGlobalTestEnvironment(new PerfEnvironment);
 
-    param_impl          = args.get<bool>("perf_run_cpu") ? "plain" : args.get<std::string>("perf_impl");
+    param_impl          = args.has("perf_run_cpu") ? "plain" : args.get<std::string>("perf_impl");
     std::string perf_strategy = args.get<std::string>("perf_strategy");
     if (perf_strategy == "default")
     {
@@ -699,18 +698,18 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
     param_max_outliers  = std::min(100., std::max(0., args.get<double>("perf_max_outliers")));
     param_min_samples   = std::max(1u, args.get<unsigned int>("perf_min_samples"));
     param_max_deviation = std::max(0., args.get<double>("perf_max_deviation"));
-    param_seed          = args.get<uint64>("perf_seed");
+    param_seed          = args.get<unsigned int>("perf_seed");
     param_time_limit    = std::max(0., args.get<double>("perf_time_limit"));
     param_force_samples = args.get<unsigned int>("perf_force_samples");
-    param_write_sanity  = args.get<bool>("perf_write_sanity");
-    param_verify_sanity = args.get<bool>("perf_verify_sanity");
+    param_write_sanity  = args.has("perf_write_sanity");
+    param_verify_sanity = args.has("perf_verify_sanity");
     param_threads  = args.get<int>("perf_threads");
 #ifdef ANDROID
     param_affinity_mask   = args.get<int>("perf_affinity_mask");
-    log_power_checkpoints = args.get<bool>("perf_log_power_checkpoints");
+    log_power_checkpoints = args.has("perf_log_power_checkpoints");
 #endif
 
-    bool param_list_impls = args.get<bool>("perf_list_impls");
+    bool param_list_impls = args.has("perf_list_impls");
 
     if (param_list_impls)
     {
@@ -731,7 +730,7 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
 
 #ifdef HAVE_CUDA
 
-    bool printOnly        = args.get<bool>("perf_cuda_info_only");
+    bool printOnly        = args.has("perf_cuda_info_only");
 
     if (printOnly)
         exit(0);
@@ -742,28 +741,28 @@ void TestBase::Init(const std::vector<std::string> & availableImpls,
 
 #ifdef HAVE_CUDA
 
-    param_cuda_device      = std::max(0, std::min(cv::gpu::getCudaEnabledDeviceCount(), args.get<int>("perf_cuda_device")));
+    param_cuda_device      = std::max(0, std::min(cv::cuda::getCudaEnabledDeviceCount(), args.get<int>("perf_cuda_device")));
 
     if (param_impl == "cuda")
     {
-        cv::gpu::DeviceInfo info(param_cuda_device);
+        cv::cuda::DeviceInfo info(param_cuda_device);
         if (!info.isCompatible())
         {
-            printf("[----------]\n[ FAILURE  ] \tDevice %s is NOT compatible with current GPU module build.\n[----------]\n", info.name().c_str()), fflush(stdout);
+            printf("[----------]\n[ FAILURE  ] \tDevice %s is NOT compatible with current CUDA module build.\n[----------]\n", info.name()), fflush(stdout);
             exit(-1);
         }
 
-        cv::gpu::setDevice(param_cuda_device);
+        cv::cuda::setDevice(param_cuda_device);
 
-        printf("[----------]\n[ GPU INFO ] \tRun test suite on %s GPU.\n[----------]\n", info.name().c_str()), fflush(stdout);
+        printf("[----------]\n[ GPU INFO ] \tRun test suite on %s GPU.\n[----------]\n", info.name()), fflush(stdout);
     }
 #endif
 
-//    if (!args.check())
-//    {
-//        args.printErrors();
-//        return;
-//    }
+    if (!args.check())
+    {
+        args.printErrors();
+        return;
+    }
 
     timeLimitDefault = param_time_limit == 0.0 ? 1 : (int64)(param_time_limit * cv::getTickFrequency());
     iterationsLimitDefault = param_force_samples == 0 ? (unsigned)(-1) : param_force_samples;
@@ -778,7 +777,7 @@ void TestBase::RecordRunParameters()
 #ifdef HAVE_CUDA
     if (param_impl == "cuda")
     {
-        cv::gpu::DeviceInfo info(param_cuda_device);
+        cv::cuda::DeviceInfo info(param_cuda_device);
         ::testing::Test::RecordProperty("cv_cuda_gpu", info.name());
     }
 #endif
@@ -1361,8 +1360,8 @@ void TestBase::RunPerfTestBody()
     {
         metrics.terminationReason = performance_metrics::TERM_EXCEPTION;
         #ifdef HAVE_CUDA
-            if (e.code == CV_GpuApiCallError)
-                cv::gpu::resetDevice();
+            if (e.code == cv::Error::GpuApiCallError)
+                cv::cuda::resetDevice();
         #endif
         FAIL() << "Expected: PerfTestBody() doesn't throw an exception.\n  Actual: it throws cv::Exception:\n  " << e.what();
     }