Home | History | Annotate | Download | only in perf
      1 #include "perf_precomp.hpp"
      2 #include "opencv2/core/core_c.h"
      3 
      4 using namespace std;
      5 using namespace cv;
      6 using namespace perf;
      7 using std::tr1::make_tuple;
      8 using std::tr1::get;
      9 
     10 CV_ENUM(ROp, CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN)
     11 typedef std::tr1::tuple<Size, MatType, ROp> Size_MatType_ROp_t;
     12 typedef perf::TestBaseWithParam<Size_MatType_ROp_t> Size_MatType_ROp;
     13 
     14 
     15 PERF_TEST_P(Size_MatType_ROp, reduceR,
     16             testing::Combine(
     17                 testing::Values(TYPICAL_MAT_SIZES),
     18                 testing::Values(TYPICAL_MAT_TYPES),
     19                 ROp::all()
     20                 )
     21             )
     22 {
     23     Size sz = get<0>(GetParam());
     24     int matType = get<1>(GetParam());
     25     int reduceOp = get<2>(GetParam());
     26 
     27     int ddepth = -1;
     28     if( CV_MAT_DEPTH(matType) < CV_32S && (reduceOp == CV_REDUCE_SUM || reduceOp == CV_REDUCE_AVG) )
     29         ddepth = CV_32S;
     30 
     31     Mat src(sz, matType);
     32     Mat vec(1, sz.width, ddepth < 0 ? matType : ddepth);
     33 
     34     declare.in(src, WARMUP_RNG).out(vec);
     35     declare.time(100);
     36 
     37     int runs = 15;
     38     TEST_CYCLE_MULTIRUN(runs) reduce(src, vec, 0, reduceOp, ddepth);
     39 
     40     SANITY_CHECK(vec, 1);
     41 }
     42 
     43 PERF_TEST_P(Size_MatType_ROp, reduceC,
     44             testing::Combine(
     45                 testing::Values(TYPICAL_MAT_SIZES),
     46                 testing::Values(TYPICAL_MAT_TYPES),
     47                 ROp::all()
     48                 )
     49             )
     50 {
     51     Size sz = get<0>(GetParam());
     52     int matType = get<1>(GetParam());
     53     int reduceOp = get<2>(GetParam());
     54 
     55     int ddepth = -1;
     56     if( CV_MAT_DEPTH(matType)< CV_32S && (reduceOp == CV_REDUCE_SUM || reduceOp == CV_REDUCE_AVG) )
     57         ddepth = CV_32S;
     58 
     59     Mat src(sz, matType);
     60     Mat vec(sz.height, 1, ddepth < 0 ? matType : ddepth);
     61 
     62     declare.in(src, WARMUP_RNG).out(vec);
     63     declare.time(100);
     64 
     65     TEST_CYCLE() reduce(src, vec, 1, reduceOp, ddepth);
     66 
     67     SANITY_CHECK(vec, 1);
     68 }
     69