From a612fa1520a90930e16f12256997f6c96c89509d Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 1 Nov 2011 15:41:43 +0000 Subject: [PATCH] Performance testing: added option to get list of all values for CV_ENUM; added perf test for cv::Sobel --- modules/core/perf/perf_stat.cpp | 4 +-- modules/imgproc/perf/perf_filters.cpp | 38 +++++++++++++++++++++++ modules/imgproc/perf/perf_inpaint.cpp | 3 +- modules/ts/include/opencv2/ts/ts_perf.hpp | 11 +++++++ modules/ts/misc/chart.py | 25 ++++++++++++++- 5 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 modules/imgproc/perf/perf_filters.cpp diff --git a/modules/core/perf/perf_stat.cpp b/modules/core/perf/perf_stat.cpp index 58718f911b..06883a730a 100644 --- a/modules/core/perf/perf_stat.cpp +++ b/modules/core/perf/perf_stat.cpp @@ -386,7 +386,7 @@ PERF_TEST_P( Size_MatType_ROp, reduceR, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( TYPICAL_MAT_TYPES ), - testing::Values( CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN ) + testing::ValuesIn(ROp::all()) ) ) { @@ -414,7 +414,7 @@ PERF_TEST_P( Size_MatType_ROp, reduceC, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( TYPICAL_MAT_TYPES ), - testing::Values( CV_REDUCE_SUM, CV_REDUCE_AVG, CV_REDUCE_MAX, CV_REDUCE_MIN ) + testing::ValuesIn(ROp::all()) ) ) { diff --git a/modules/imgproc/perf/perf_filters.cpp b/modules/imgproc/perf/perf_filters.cpp new file mode 100644 index 0000000000..74eebd09f2 --- /dev/null +++ b/modules/imgproc/perf/perf_filters.cpp @@ -0,0 +1,38 @@ +#include "perf_precomp.hpp" + +using namespace std; +using namespace cv; +using namespace perf; + +using std::tr1::make_tuple; +using std::tr1::get; + +CV_ENUM(SobelBorderType, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT_101) + +typedef std::tr1::tuple, int, SobelBorderType> Size_dx_dy_kernel_Border_t; +typedef perf::TestBaseWithParam Size_dx_dy_kernel_Border; + +PERF_TEST_P(Size_dx_dy_kernel_Border, sobel, + testing::Combine( + testing::Values(szVGA, szQVGA), + testing::Values(make_tuple(0, 1), make_tuple(1, 0), make_tuple(1, 1), make_tuple(0, 2), make_tuple(2, 0), make_tuple(2, 2)), + testing::Values(3, 5), + testing::ValuesIn(SobelBorderType::all()) + ) + ) +{ + Size size = get<0>(GetParam()); + int dx = get<0>(get<1>(GetParam())); + int dy = get<1>(get<1>(GetParam())); + int ksize = get<2>(GetParam()); + SobelBorderType border = get<3>(GetParam()); + + Mat src(size, CV_8U); + Mat dst(size, CV_32F); + + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE(100) { Sobel(src, dst, CV_32F, dx, dy, ksize, 1, 0, border); } + + SANITY_CHECK(dst); +} diff --git a/modules/imgproc/perf/perf_inpaint.cpp b/modules/imgproc/perf/perf_inpaint.cpp index 22bb7f3270..bbd8e686ba 100644 --- a/modules/imgproc/perf/perf_inpaint.cpp +++ b/modules/imgproc/perf/perf_inpaint.cpp @@ -19,7 +19,8 @@ CV_EXPORTS_W void inpaint( InputArray src, InputArray inpaintMask, PERF_TEST_P( InpaintArea_InpaintingMethod, inpaint, testing::Combine( SZ_ALL_SMALL, - testing::Values( (int)INPAINT_NS, (int)INPAINT_TELEA )) + testing::ValuesIn(InpaintingMethod::all()) + ) ) { Mat src = imread( getDataPath("gpu/hog/road.png") ); diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp index 5f8a816b64..f448b1c0dd 100644 --- a/modules/ts/include/opencv2/ts/ts_perf.hpp +++ b/modules/ts/include/opencv2/ts/ts_perf.hpp @@ -101,6 +101,17 @@ public:\ }\ *os << "UNKNOWN";\ }\ + struct Container{\ + typedef class_name value_type;\ + Container(class_name* first, size_t len): _begin(first), _end(first+len){}\ + const class_name* begin() const {return _begin;}\ + const class_name* end() const {return _end;}\ + private: class_name *_begin, *_end;\ + };\ + static Container all(){\ + static class_name vals[] = {__VA_ARGS__};\ + return Container(vals, sizeof(vals)/sizeof(vals[0]));\ + }\ private: int _val;\ };\ inline void PrintTo(const class_name& t, std::ostream* os) { t.PrintTo(os); } diff --git a/modules/ts/misc/chart.py b/modules/ts/misc/chart.py index f17395b95a..937b433191 100644 --- a/modules/ts/misc/chart.py +++ b/modules/ts/misc/chart.py @@ -40,7 +40,30 @@ def getValueParams(test): param = param[1:] if param.endswith(")"): param = param[:-1] - return [p.strip() for p in param.split(",")] + args = [] + prev_pos = 0 + start = 0 + balance = 0 + while True: + idx = param.find(",", prev_pos) + if idx < 0: + break + idxlb = param.find("(", prev_pos, idx) + while idxlb >= 0: + balance += 1 + idxlb = param.find("(", idxlb+1, idx) + idxrb = param.find(")", prev_pos, idx) + while idxrb >= 0: + balance -= 1 + idxrb = param.find(")", idxrb+1, idx) + assert(balance >= 0) + if balance == 0: + args.append(param[start:idx].strip()) + start = idx + 1 + prev_pos = idx + 1 + args.append(param[start:].strip()) + return args + #return [p.strip() for p in param.split(",")] def nextPermutation(indexes, lists, x, y): idx = len(indexes)-1