2011-12-29 17:46:16 +01:00
|
|
|
#include "perf_precomp.hpp"
|
2012-09-19 16:03:50 +02:00
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
using namespace std;
|
|
|
|
using namespace cv;
|
|
|
|
using namespace perf;
|
|
|
|
using std::tr1::make_tuple;
|
|
|
|
using std::tr1::get;
|
|
|
|
|
2013-01-16 08:57:24 +01:00
|
|
|
#define TYPICAL_MAT_SIZES_CORE_ARITHM ::szVGA, ::sz720p, ::sz1080p
|
2012-09-19 16:03:50 +02:00
|
|
|
#define TYPICAL_MAT_TYPES_CORE_ARITHM CV_8UC1, CV_8SC1, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, CV_8UC4, CV_32SC1, CV_32FC1
|
2011-12-29 17:46:16 +01:00
|
|
|
#define TYPICAL_MATS_CORE_ARITHM testing::Combine( testing::Values( TYPICAL_MAT_SIZES_CORE_ARITHM ), testing::Values( TYPICAL_MAT_TYPES_CORE_ARITHM ) )
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType, min, TYPICAL_MATS_CORE_ARITHM)
|
|
|
|
{
|
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
|
|
|
cv::Mat a = Mat(sz, type);
|
|
|
|
cv::Mat b = Mat(sz, type);
|
|
|
|
cv::Mat c = Mat(sz, type);
|
|
|
|
|
|
|
|
declare.in(a, b, WARMUP_RNG).out(c);
|
|
|
|
|
|
|
|
TEST_CYCLE() min(a, b, c);
|
|
|
|
|
|
|
|
SANITY_CHECK(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType, minScalar, TYPICAL_MATS_CORE_ARITHM)
|
|
|
|
{
|
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
|
|
|
cv::Mat a = Mat(sz, type);
|
|
|
|
cv::Scalar b;
|
|
|
|
cv::Mat c = Mat(sz, type);
|
|
|
|
|
|
|
|
declare.in(a, b, WARMUP_RNG).out(c);
|
|
|
|
|
|
|
|
TEST_CYCLE() min(a, b, c);
|
|
|
|
|
|
|
|
SANITY_CHECK(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType, max, TYPICAL_MATS_CORE_ARITHM)
|
|
|
|
{
|
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
|
|
|
cv::Mat a = Mat(sz, type);
|
|
|
|
cv::Mat b = Mat(sz, type);
|
|
|
|
cv::Mat c = Mat(sz, type);
|
|
|
|
|
|
|
|
declare.in(a, b, WARMUP_RNG).out(c);
|
|
|
|
|
|
|
|
TEST_CYCLE() max(a, b, c);
|
|
|
|
|
|
|
|
SANITY_CHECK(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType, maxScalar, TYPICAL_MATS_CORE_ARITHM)
|
|
|
|
{
|
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
|
|
|
cv::Mat a = Mat(sz, type);
|
|
|
|
cv::Scalar b;
|
|
|
|
cv::Mat c = Mat(sz, type);
|
|
|
|
|
|
|
|
declare.in(a, b, WARMUP_RNG).out(c);
|
|
|
|
|
|
|
|
TEST_CYCLE() max(a, b, c);
|
|
|
|
|
|
|
|
SANITY_CHECK(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType, absdiff, TYPICAL_MATS_CORE_ARITHM)
|
|
|
|
{
|
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
|
|
|
cv::Mat a = Mat(sz, type);
|
|
|
|
cv::Mat b = Mat(sz, type);
|
|
|
|
cv::Mat c = Mat(sz, type);
|
|
|
|
|
|
|
|
declare.in(a, b, WARMUP_RNG).out(c);
|
|
|
|
|
2012-10-08 16:06:17 +02:00
|
|
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
|
|
|
{
|
|
|
|
//see ticket 1529: absdiff can be without saturation on 32S
|
|
|
|
a /= 2;
|
|
|
|
b /= 2;
|
|
|
|
}
|
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
TEST_CYCLE() absdiff(a, b, c);
|
|
|
|
|
2012-10-08 16:06:17 +02:00
|
|
|
SANITY_CHECK(c, 1e-8);
|
2011-12-29 17:46:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType, absdiffScalar, TYPICAL_MATS_CORE_ARITHM)
|
|
|
|
{
|
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
|
|
|
cv::Mat a = Mat(sz, type);
|
|
|
|
cv::Scalar b;
|
|
|
|
cv::Mat c = Mat(sz, type);
|
|
|
|
|
|
|
|
declare.in(a, b, WARMUP_RNG).out(c);
|
|
|
|
|
2012-10-08 16:06:17 +02:00
|
|
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
|
|
|
{
|
|
|
|
//see ticket 1529: absdiff can be without saturation on 32S
|
|
|
|
a /= 2;
|
|
|
|
b /= 2;
|
|
|
|
}
|
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
TEST_CYCLE() absdiff(a, b, c);
|
|
|
|
|
2012-10-08 16:06:17 +02:00
|
|
|
SANITY_CHECK(c, 1e-8);
|
2011-12-29 17:46:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType, add, TYPICAL_MATS_CORE_ARITHM)
|
|
|
|
{
|
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
|
|
|
cv::Mat a = Mat(sz, type);
|
|
|
|
cv::Mat b = Mat(sz, type);
|
|
|
|
cv::Mat c = Mat(sz, type);
|
|
|
|
|
|
|
|
declare.in(a, b, WARMUP_RNG).out(c);
|
2012-11-28 11:13:24 +01:00
|
|
|
declare.time(50);
|
2011-12-29 17:46:16 +01:00
|
|
|
|
2012-10-08 16:06:17 +02:00
|
|
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
|
|
|
{
|
|
|
|
//see ticket 1529: add can be without saturation on 32S
|
|
|
|
a /= 2;
|
|
|
|
b /= 2;
|
|
|
|
}
|
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
TEST_CYCLE() add(a, b, c);
|
|
|
|
|
2012-10-08 16:06:17 +02:00
|
|
|
SANITY_CHECK(c, 1e-8);
|
2011-12-29 17:46:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType, addScalar, TYPICAL_MATS_CORE_ARITHM)
|
|
|
|
{
|
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
|
|
|
cv::Mat a = Mat(sz, type);
|
|
|
|
cv::Scalar b;
|
|
|
|
cv::Mat c = Mat(sz, type);
|
|
|
|
|
|
|
|
declare.in(a, b, WARMUP_RNG).out(c);
|
|
|
|
|
2012-10-08 16:06:17 +02:00
|
|
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
|
|
|
{
|
|
|
|
//see ticket 1529: add can be without saturation on 32S
|
|
|
|
a /= 2;
|
|
|
|
b /= 2;
|
|
|
|
}
|
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
TEST_CYCLE() add(a, b, c);
|
|
|
|
|
2012-10-08 16:06:17 +02:00
|
|
|
SANITY_CHECK(c, 1e-8);
|
2011-12-29 17:46:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType, subtract, TYPICAL_MATS_CORE_ARITHM)
|
|
|
|
{
|
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
|
|
|
cv::Mat a = Mat(sz, type);
|
|
|
|
cv::Mat b = Mat(sz, type);
|
|
|
|
cv::Mat c = Mat(sz, type);
|
|
|
|
|
|
|
|
declare.in(a, b, WARMUP_RNG).out(c);
|
|
|
|
|
2012-10-08 16:06:17 +02:00
|
|
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
|
|
|
{
|
|
|
|
//see ticket 1529: subtract can be without saturation on 32S
|
|
|
|
a /= 2;
|
|
|
|
b /= 2;
|
|
|
|
}
|
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
TEST_CYCLE() subtract(a, b, c);
|
|
|
|
|
2012-10-08 16:06:17 +02:00
|
|
|
SANITY_CHECK(c, 1e-8);
|
2011-12-29 17:46:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType, subtractScalar, TYPICAL_MATS_CORE_ARITHM)
|
|
|
|
{
|
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
|
|
|
cv::Mat a = Mat(sz, type);
|
|
|
|
cv::Scalar b;
|
|
|
|
cv::Mat c = Mat(sz, type);
|
|
|
|
|
|
|
|
declare.in(a, b, WARMUP_RNG).out(c);
|
|
|
|
|
2012-10-08 16:06:17 +02:00
|
|
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
|
|
|
{
|
|
|
|
//see ticket 1529: subtract can be without saturation on 32S
|
|
|
|
a /= 2;
|
|
|
|
b /= 2;
|
|
|
|
}
|
|
|
|
|
2011-12-29 17:46:16 +01:00
|
|
|
TEST_CYCLE() subtract(a, b, c);
|
|
|
|
|
2012-10-08 16:06:17 +02:00
|
|
|
SANITY_CHECK(c, 1e-8);
|
2011-12-29 17:46:16 +01:00
|
|
|
}
|
2014-01-04 11:56:32 +01:00
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType, multiply, TYPICAL_MATS_CORE_ARITHM)
|
|
|
|
{
|
2014-01-04 12:01:32 +01:00
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
2014-01-13 12:55:49 +01:00
|
|
|
cv::Mat a(sz, type), b(sz, type), c(sz, type);
|
2014-01-04 11:56:32 +01:00
|
|
|
|
2014-01-04 12:01:32 +01:00
|
|
|
declare.in(a, b, WARMUP_RNG).out(c);
|
|
|
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
|
|
|
{
|
2014-01-04 13:09:30 +01:00
|
|
|
//According to docs, saturation is not applied when result is 32bit integer
|
|
|
|
a /= (2 << 16);
|
|
|
|
b /= (2 << 16);
|
2014-01-04 12:01:32 +01:00
|
|
|
}
|
2014-01-04 11:56:32 +01:00
|
|
|
|
2014-01-04 12:01:32 +01:00
|
|
|
TEST_CYCLE() multiply(a, b, c);
|
2014-01-04 11:56:32 +01:00
|
|
|
|
2014-01-04 12:01:32 +01:00
|
|
|
SANITY_CHECK(c, 1e-8);
|
2014-01-04 11:56:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PERF_TEST_P(Size_MatType, multiplyScale, TYPICAL_MATS_CORE_ARITHM)
|
|
|
|
{
|
2014-01-04 12:01:32 +01:00
|
|
|
Size sz = get<0>(GetParam());
|
|
|
|
int type = get<1>(GetParam());
|
2014-01-13 12:55:49 +01:00
|
|
|
cv::Mat a(sz, type), b(sz, type), c(sz, type);
|
2014-01-04 12:01:32 +01:00
|
|
|
double scale = 0.5;
|
2014-01-04 11:56:32 +01:00
|
|
|
|
2014-01-04 12:01:32 +01:00
|
|
|
declare.in(a, b, WARMUP_RNG).out(c);
|
2014-01-04 11:56:32 +01:00
|
|
|
|
2014-01-04 12:01:32 +01:00
|
|
|
if (CV_MAT_DEPTH(type) == CV_32S)
|
|
|
|
{
|
|
|
|
//According to docs, saturation is not applied when result is 32bit integer
|
|
|
|
a /= (2 << 16);
|
|
|
|
b /= (2 << 16);
|
|
|
|
}
|
2014-01-04 11:56:32 +01:00
|
|
|
|
2014-01-04 12:01:32 +01:00
|
|
|
TEST_CYCLE() multiply(a, b, c, scale);
|
2014-01-04 11:56:32 +01:00
|
|
|
|
2014-01-04 12:01:32 +01:00
|
|
|
SANITY_CHECK(c, 1e-8);
|
2014-01-04 11:56:32 +01:00
|
|
|
}
|