From 582bb3c311dac87ce2ce1ccb7647895a099c0598 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 30 Jun 2017 22:47:27 +0000 Subject: [PATCH] core(perf): added Hamming tests --- modules/core/perf/perf_norm.cpp | 58 ++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/modules/core/perf/perf_norm.cpp b/modules/core/perf/perf_norm.cpp index 2df2d4a1e0..1ea6b2ab2c 100644 --- a/modules/core/perf/perf_norm.cpp +++ b/modules/core/perf/perf_norm.cpp @@ -6,8 +6,10 @@ using namespace perf; using std::tr1::make_tuple; using std::tr1::get; +#define HAMMING_NORM_SIZES cv::Size(640, 480), cv::Size(1920, 1080) +#define HAMMING_NORM_TYPES CV_8UC1 -CV_FLAGS(NormType, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX) +CV_FLAGS(NormType, NORM_HAMMING2, NORM_HAMMING, NORM_INF, NORM_L1, NORM_L2, NORM_TYPE_MASK, NORM_RELATIVE, NORM_MINMAX) typedef std::tr1::tuple Size_MatType_NormType_t; typedef perf::TestBaseWithParam Size_MatType_NormType; @@ -103,6 +105,60 @@ PERF_TEST_P(Size_MatType_NormType, norm2_mask, SANITY_CHECK(n, 1e-5, ERROR_RELATIVE); } +namespace { +typedef std::tr1::tuple PerfHamming_t; +typedef perf::TestBaseWithParam PerfHamming; + +PERF_TEST_P(PerfHamming, norm, + testing::Combine( + testing::Values(NORM_HAMMING, NORM_HAMMING2), + testing::Values(HAMMING_NORM_TYPES), + testing::Values(HAMMING_NORM_SIZES) + ) + ) +{ + Size sz = get<2>(GetParam()); + int matType = get<1>(GetParam()); + int normType = get<0>(GetParam()); + + Mat src(sz, matType); + double n; + + declare.in(src, WARMUP_RNG); + + TEST_CYCLE() n = norm(src, normType); + + (void)n; + SANITY_CHECK_NOTHING(); +} + +PERF_TEST_P(PerfHamming, norm2, + testing::Combine( + testing::Values(NORM_HAMMING, NORM_HAMMING2), + testing::Values(HAMMING_NORM_TYPES), + testing::Values(HAMMING_NORM_SIZES) + ) + ) +{ + Size sz = get<2>(GetParam()); + int matType = get<1>(GetParam()); + int normType = get<0>(GetParam()); + + Mat src1(sz, matType); + Mat src2(sz, matType); + double n; + + declare.in(src1, src2, WARMUP_RNG); + + TEST_CYCLE() n = norm(src1, src2, normType); + + (void)n; + SANITY_CHECK_NOTHING(); +} + +} + + PERF_TEST_P(Size_MatType_NormType, normalize, testing::Combine( testing::Values(TYPICAL_MAT_SIZES),