Files
opencv-MIRROR/modules/core/perf/perf_compare.cpp
Andrei Fedorov 2e0c9a44e6 Merge pull request #30663 from intel-staging:andreyfe1/5.x/extend_perf_tests
Porting of perf tests extension from 4.x to 5.x - #30663

Following PRs are being ported:
* #29908
* #29922 
* #29972

No more changes are introduced.
PR for opencv-extra: https://github.com/opencv/opencv_extra/pull/1458

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2026-11-09 11:46:44 +03:00

63 lines
2.0 KiB
C++

#include "perf_precomp.hpp"
namespace opencv_test
{
using namespace perf;
CV_ENUM(CmpType, CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE)
typedef tuple<Size, MatType, CmpType> Size_MatType_CmpType_t;
typedef perf::TestBaseWithParam<Size_MatType_CmpType_t> Size_MatType_CmpType;
PERF_TEST_P( Size_MatType_CmpType, compare,
testing::Combine(
testing::Values(::perf::szVGA, ::perf::sz1080p, cv::Size(127, 61)),
testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1),
CmpType::all()
)
)
{
Size sz = get<0>(GetParam());
int matType1 = get<1>(GetParam());
CmpType cmpType = get<2>(GetParam());
Mat src1(sz, matType1);
Mat src2(sz, matType1);
Mat dst(sz, CV_8UC(CV_MAT_CN(matType1)));
declare.in(src1, src2, WARMUP_RNG).out(dst);
TEST_CYCLE() cv::compare(src1, src2, dst, cmpType);
// accuracy is covered by the accuracy tests; regression data does not exist for every
// size in the grid (127x61 guards per-call overhead only)
SANITY_CHECK_NOTHING();
}
PERF_TEST_P( Size_MatType_CmpType, compareScalar,
testing::Combine(
testing::Values(TYPICAL_MAT_SIZES),
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
CmpType::all()
)
)
{
Size sz = get<0>(GetParam());
int matType = get<1>(GetParam());
CmpType cmpType = get<2>(GetParam());
Mat src1(sz, matType);
Scalar src2;
Mat dst(sz, CV_8UC(CV_MAT_CN(matType)));
declare.in(src1, src2, WARMUP_RNG).out(dst);
int runs = (sz.width <= 640) ? 8 : 1;
TEST_CYCLE_MULTIRUN(runs) cv::compare(src1, src2, dst, cmpType);
// TEMP: cv::compare with a multi-channel Scalar is now PER-CHANNEL (like cv::add), whereas the
// recorded sanity data assumes the legacy scalar[0]-broadcast; disable the value check for now.
SANITY_CHECK_NOTHING();
}
} // namespace