Skip to content

Commit

Permalink
master-like performance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov committed Feb 28, 2014
1 parent 7dc22b4 commit c1c3139
Show file tree
Hide file tree
Showing 22 changed files with 667 additions and 556 deletions.
289 changes: 171 additions & 118 deletions modules/ocl/perf/perf_arithm.cpp

Large diffs are not rendered by default.

24 changes: 10 additions & 14 deletions modules/ocl/perf/perf_bgfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ PERF_TEST_P(VideoMOGFixture, MOG,
///////////// MOG2 ////////////////////////

typedef tuple<string, int> VideoMOG2ParamType;
typedef TestBaseWithParam<VideoMOG2ParamType> VideoMOG2Fixture;
typedef TestBaseWithParam<VideoMOG2ParamType> MOG2_Apply;

PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on buildslave
::testing::Combine(::testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
::testing::Values(1, 3)))
OCL_PERF_TEST_P(MOG2_Apply, Mog2,
testing::Combine(testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
testing::Values(1, 3)))
{
VideoMOG2ParamType params = GetParam();

Expand All @@ -195,9 +195,7 @@ PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on b
foreground.release();

for (int i = 0; i < nFrame; i++)
{
mog2(frame_buffer[i], foreground);
}
}
SANITY_CHECK(foreground);
}
Expand All @@ -210,9 +208,7 @@ PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on b
cv::ocl::MOG2 d_mog2;
foreground_d.release();
for (int i = 0; i < nFrame; i++)
{
d_mog2(frame_buffer_ocl[i], foreground_d);
}
}
foreground_d.download(foreground);
SANITY_CHECK(foreground);
Expand All @@ -223,11 +219,11 @@ PERF_TEST_P(VideoMOG2Fixture, DISABLED_MOG2, // TODO Disabled: random hungs on b

///////////// MOG2_GetBackgroundImage //////////////////

typedef TestBaseWithParam<VideoMOG2ParamType> Video_MOG2GetBackgroundImage;
typedef TestBaseWithParam<VideoMOG2ParamType> MOG2_GetBackgroundImage;

PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2,
::testing::Combine(::testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
::testing::Values(3)))
OCL_PERF_TEST_P(MOG2_GetBackgroundImage, Mog2,
testing::Combine(testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
testing::Values(3)))
{
VideoMOG2ParamType params = GetParam();

Expand All @@ -248,7 +244,7 @@ PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2,
cv::ocl::oclMat foreground_d;
cv::ocl::oclMat background_d;

if(RUN_PLAIN_IMPL)
if (RUN_PLAIN_IMPL)
{
TEST_CYCLE()
{
Expand All @@ -264,7 +260,7 @@ PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2,
}
SANITY_CHECK(background);
}
else if(RUN_OCL_IMPL)
else if (RUN_OCL_IMPL)
{
prepareData(frame_buffer, frame_buffer_ocl);
CV_Assert((int)(frame_buffer_ocl.size()) == nFrame);
Expand Down
6 changes: 3 additions & 3 deletions modules/ocl/perf/perf_blend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ typedef void (*blendFunction)(const Mat &img1, const Mat &img2,
const Mat &weights1, const Mat &weights2,
Mat &result_gold);

typedef Size_MatType blendLinearFixture;
typedef Size_MatType BlendLinearFixture;

PERF_TEST_P(blendLinearFixture, blendLinear, ::testing::Combine(
OCL_TYPICAL_MAT_SIZES, testing::Values(CV_8UC1, CV_8UC3, CV_32FC1)))
OCL_PERF_TEST_P(BlendLinearFixture, BlendLinear,
::testing::Combine(OCL_TEST_SIZES, OCL_PERF_ENUM(CV_32FC1, CV_32FC4)))
{
Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
Expand Down
35 changes: 10 additions & 25 deletions modules/ocl/perf/perf_brute_force_matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,17 @@

using namespace perf;

#define OCL_BFMATCHER_TYPICAL_MAT_SIZES ::testing::Values(cv::Size(128, 500), cv::Size(128, 1000), cv::Size(128, 2000))

//////////////////// BruteForceMatch /////////////////

typedef TestBaseWithParam<Size> BruteForceMatcherFixture;

PERF_TEST_P(BruteForceMatcherFixture, match,
OCL_BFMATCHER_TYPICAL_MAT_SIZES)
OCL_PERF_TEST_P(BruteForceMatcherFixture, Match, OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3))
{
const Size srcSize = GetParam();

vector<DMatch> matches;
Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
declare.in(query, train).time(srcSize.height == 2000 ? 9 : 4 );
Mat query(srcSize, CV_32FC1), train(srcSize, CV_32FC1);
declare.in(query, train);
randu(query, 0.0f, 1.0f);
randu(train, 0.0f, 1.0f);

Expand All @@ -75,21 +72,17 @@ PERF_TEST_P(BruteForceMatcherFixture, match,
{
ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist);
ocl::oclMat oclQuery(query), oclTrain(train);
ocl::oclMat oclTrainIdx, oclDistance;

OCL_TEST_CYCLE()
oclMatcher.matchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance);

oclMatcher.matchDownload(oclTrainIdx, oclDistance, matches);
oclMatcher.match(oclQuery, oclTrain, matches);

SANITY_CHECK_MATCHES(matches, 1e-5);
}
else
OCL_PERF_ELSE
}

PERF_TEST_P(BruteForceMatcherFixture, knnMatch,
OCL_BFMATCHER_TYPICAL_MAT_SIZES)
OCL_PERF_TEST_P(BruteForceMatcherFixture, KnnMatch, OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3))
{
const Size srcSize = GetParam();

Expand All @@ -99,8 +92,6 @@ PERF_TEST_P(BruteForceMatcherFixture, knnMatch,
randu(train, 0.0f, 1.0f);

declare.in(query, train);
if (srcSize.height == 2000)
declare.time(9);

if (RUN_PLAIN_IMPL)
{
Expand All @@ -115,10 +106,10 @@ PERF_TEST_P(BruteForceMatcherFixture, knnMatch,
{
ocl::BruteForceMatcher_OCL_base oclMatcher(ocl::BruteForceMatcher_OCL_base::L2Dist);
ocl::oclMat oclQuery(query), oclTrain(train);
ocl::oclMat oclTrainIdx, oclDistance, oclAllDist;
ocl::oclMat oclTrainIdx, oclDistance;

OCL_TEST_CYCLE()
oclMatcher.knnMatchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance, oclAllDist, 2);
oclMatcher.knnMatch(oclQuery, oclTrain, matches, 2);

oclMatcher.knnMatchDownload(oclTrainIdx, oclDistance, matches);

Expand All @@ -130,22 +121,18 @@ PERF_TEST_P(BruteForceMatcherFixture, knnMatch,
OCL_PERF_ELSE
}

PERF_TEST_P(BruteForceMatcherFixture, radiusMatch,
OCL_BFMATCHER_TYPICAL_MAT_SIZES)
OCL_PERF_TEST_P(BruteForceMatcherFixture, RadiusMatch, OCL_PERF_ENUM(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3))
{
const Size srcSize = GetParam();

const float max_distance = 2.0f;
vector<vector<DMatch> > matches(2);
Mat query(srcSize, CV_32F), train(srcSize, CV_32F);
Mat query(srcSize, CV_32FC1), train(srcSize, CV_32FC1);
declare.in(query, train);

randu(query, 0.0f, 1.0f);
randu(train, 0.0f, 1.0f);

if (srcSize.height == 2000)
declare.time(9.15);

if (RUN_PLAIN_IMPL)
{
cv::BFMatcher matcher(NORM_L2);
Expand All @@ -162,7 +149,7 @@ PERF_TEST_P(BruteForceMatcherFixture, radiusMatch,
ocl::oclMat oclTrainIdx, oclDistance, oclNMatches;

OCL_TEST_CYCLE()
oclMatcher.radiusMatchSingle(oclQuery, oclTrain, oclTrainIdx, oclDistance, oclNMatches, max_distance);
oclMatcher.radiusMatch(oclQuery, oclTrain, matches, max_distance);

oclMatcher.radiusMatchDownload(oclTrainIdx, oclDistance, oclNMatches, matches);

Expand All @@ -173,5 +160,3 @@ PERF_TEST_P(BruteForceMatcherFixture, radiusMatch,
else
OCL_PERF_ELSE
}

#undef OCL_BFMATCHER_TYPICAL_MAT_SIZES
19 changes: 14 additions & 5 deletions modules/ocl/perf/perf_canny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,21 @@
#include "perf_precomp.hpp"

using namespace perf;
using std::tr1::tuple;
using std::tr1::get;

///////////// Canny ////////////////////////

PERF_TEST(CannyFixture, Canny)
typedef tuple<int, bool> CannyParams;
typedef TestBaseWithParam<CannyParams> CannyFixture;

OCL_PERF_TEST_P(CannyFixture, Canny,
::testing::Combine(OCL_PERF_ENUM(3, 5), testing::Bool()))
{
const CannyParams params = GetParam();
int apertureSize = get<0>(params);
bool L2Grad = get<1>(params);

Mat img = imread(getDataPath("gpu/stereobm/aloe-L.png"), cv::IMREAD_GRAYSCALE),
edges(img.size(), CV_8UC1);
ASSERT_TRUE(!img.empty()) << "can't open aloe-L.png";
Expand All @@ -61,16 +71,15 @@ PERF_TEST(CannyFixture, Canny)
{
ocl::oclMat oclImg(img), oclEdges(img.size(), CV_8UC1);

OCL_TEST_CYCLE() ocl::Canny(oclImg, oclEdges, 50.0, 100.0);
OCL_TEST_CYCLE() ocl::Canny(oclImg, oclEdges, 50.0, 100.0, apertureSize, L2Grad);
oclEdges.download(edges);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() Canny(img, edges, 50.0, 100.0);
TEST_CYCLE() Canny(img, edges, 50.0, 100.0, apertureSize, L2Grad);
}
else
OCL_PERF_ELSE

int value = 0;
SANITY_CHECK(value);
SANITY_CHECK_NOTHING();
}
50 changes: 25 additions & 25 deletions modules/ocl/perf/perf_color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,36 +52,36 @@ using std::tr1::make_tuple;

///////////// cvtColor////////////////////////

CV_ENUM(ConversionTypes, CV_RGB2GRAY, CV_RGB2BGR, CV_RGB2YUV, CV_YUV2RGB, CV_RGB2YCrCb,
CV_YCrCb2RGB, CV_RGB2XYZ, CV_XYZ2RGB, CV_RGB2HSV, CV_HSV2RGB, CV_RGB2HLS,
CV_HLS2RGB, CV_BGR5652BGR, CV_BGR2BGR565, CV_RGBA2mRGBA, CV_mRGBA2RGBA, CV_YUV2RGB_NV12)
CV_ENUM(ConversionTypes, COLOR_RGB2GRAY, COLOR_RGB2BGR, COLOR_RGB2YUV, COLOR_YUV2RGB, COLOR_RGB2YCrCb,
COLOR_YCrCb2RGB, COLOR_RGB2XYZ, COLOR_XYZ2RGB, COLOR_RGB2HSV, COLOR_HSV2RGB, COLOR_RGB2HLS,
COLOR_HLS2RGB, COLOR_BGR5652BGR, COLOR_BGR2BGR565, COLOR_RGBA2mRGBA, COLOR_mRGBA2RGBA, COLOR_YUV2RGB_NV12)

typedef tuple<Size, tuple<ConversionTypes, int, int> > cvtColorParams;
typedef TestBaseWithParam<cvtColorParams> cvtColorFixture;
typedef tuple<Size, tuple<ConversionTypes, int, int> > CvtColorParams;
typedef TestBaseWithParam<CvtColorParams> CvtColorFixture;

PERF_TEST_P(cvtColorFixture, cvtColor, testing::Combine(
testing::Values(Size(1000, 1002), Size(2000, 2004), Size(4000, 4008)),
OCL_PERF_TEST_P(CvtColorFixture, CvtColor, testing::Combine(
OCL_TEST_SIZES,
testing::Values(
make_tuple(ConversionTypes(CV_RGB2GRAY), 3, 1),
make_tuple(ConversionTypes(CV_RGB2BGR), 3, 3),
make_tuple(ConversionTypes(CV_RGB2YUV), 3, 3),
make_tuple(ConversionTypes(CV_YUV2RGB), 3, 3),
make_tuple(ConversionTypes(CV_RGB2YCrCb), 3, 3),
make_tuple(ConversionTypes(CV_YCrCb2RGB), 3, 3),
make_tuple(ConversionTypes(CV_RGB2XYZ), 3, 3),
make_tuple(ConversionTypes(CV_XYZ2RGB), 3, 3),
make_tuple(ConversionTypes(CV_RGB2HSV), 3, 3),
make_tuple(ConversionTypes(CV_HSV2RGB), 3, 3),
make_tuple(ConversionTypes(CV_RGB2HLS), 3, 3),
make_tuple(ConversionTypes(CV_HLS2RGB), 3, 3),
make_tuple(ConversionTypes(CV_BGR5652BGR), 2, 3),
make_tuple(ConversionTypes(CV_BGR2BGR565), 3, 2),
make_tuple(ConversionTypes(CV_RGBA2mRGBA), 4, 4),
make_tuple(ConversionTypes(CV_mRGBA2RGBA), 4, 4),
make_tuple(ConversionTypes(CV_YUV2RGB_NV12), 1, 3)
make_tuple(ConversionTypes(COLOR_RGB2GRAY), 3, 1),
make_tuple(ConversionTypes(COLOR_RGB2BGR), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2YUV), 3, 3),
make_tuple(ConversionTypes(COLOR_YUV2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2YCrCb), 3, 3),
make_tuple(ConversionTypes(COLOR_YCrCb2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2XYZ), 3, 3),
make_tuple(ConversionTypes(COLOR_XYZ2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2HSV), 3, 3),
make_tuple(ConversionTypes(COLOR_HSV2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_RGB2HLS), 3, 3),
make_tuple(ConversionTypes(COLOR_HLS2RGB), 3, 3),
make_tuple(ConversionTypes(COLOR_BGR5652BGR), 2, 3),
make_tuple(ConversionTypes(COLOR_BGR2BGR565), 3, 2),
make_tuple(ConversionTypes(COLOR_RGBA2mRGBA), 4, 4),
make_tuple(ConversionTypes(COLOR_mRGBA2RGBA), 4, 4),
make_tuple(ConversionTypes(COLOR_YUV2RGB_NV12), 1, 3)
)))
{
cvtColorParams params = GetParam();
CvtColorParams params = GetParam();
const Size srcSize = get<0>(params);
const tuple<int, int, int> conversionParams = get<1>(params);
const int code = get<0>(conversionParams), scn = get<1>(conversionParams),
Expand Down
17 changes: 13 additions & 4 deletions modules/ocl/perf/perf_fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,25 @@
#include "perf_precomp.hpp"

using namespace perf;
using std::tr1::tuple;
using std::tr1::get;

///////////// dft ////////////////////////

typedef TestBaseWithParam<Size> dftFixture;

#ifdef HAVE_CLAMDFFT

PERF_TEST_P(dftFixture, dft, OCL_TYPICAL_MAT_SIZES)
typedef tuple<Size, int> DftParams;
typedef TestBaseWithParam<DftParams> DftFixture;

OCL_PERF_TEST_P(DftFixture, Dft, ::testing::Combine(testing::Values(OCL_SIZE_1, OCL_SIZE_2, OCL_SIZE_3),
::testing::Values((int)DFT_ROWS, (int)DFT_SCALE, (int)DFT_INVERSE,
(int)DFT_INVERSE | DFT_SCALE, (int)DFT_ROWS | DFT_INVERSE)))
{
const Size srcSize = GetParam();
const Size_MatType_t params = GetParam();
const Size srcSize = get<0>(params);
const int flags = get<1>(params);

Mat src(srcSize, CV_32FC2), dst;
randu(src, 0.0f, 1.0f);
Expand All @@ -69,15 +78,15 @@ PERF_TEST_P(dftFixture, dft, OCL_TYPICAL_MAT_SIZES)
{
ocl::oclMat oclSrc(src), oclDst;

OCL_TEST_CYCLE() cv::ocl::dft(oclSrc, oclDst);
OCL_TEST_CYCLE() cv::ocl::dft(oclSrc, oclDst, Size(), flags | DFT_COMPLEX_OUTPUT);

oclDst.download(dst);

SANITY_CHECK(dst, 1.5);
}
else if (RUN_PLAIN_IMPL)
{
TEST_CYCLE() cv::dft(src, dst);
TEST_CYCLE() cv::dft(src, dst, flags | DFT_COMPLEX_OUTPUT);

SANITY_CHECK(dst);
}
Expand Down
Loading

0 comments on commit c1c3139

Please sign in to comment.