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