Commit e9596dee authored by Ilya Lysenkov's avatar Ilya Lysenkov

Added timing test for BruteForceMatcher

parent 254d6454
......@@ -10,14 +10,19 @@ protected:
void run( int );
};
BruteForceMatcherTest::BruteForceMatcherTest() : CvTest( "BruteForceMatcher", "BruteForceMatcher")
struct CV_EXPORTS L2Fake : public L2<float>
{
};
BruteForceMatcherTest::BruteForceMatcherTest() : CvTest( "BruteForceMatcher", "BruteForceMatcher::matchImpl")
{
support_testing_modes = CvTS::TIMING_MODE;
}
void BruteForceMatcherTest::run( int )
{
const int dimensions = 64;
const int descriptorsNumber = 1024;
const int descriptorsNumber = 5000;
Mat train = Mat( descriptorsNumber, dimensions, CV_32FC1);
Mat query = Mat( descriptorsNumber, dimensions, CV_32FC1);
......@@ -40,14 +45,32 @@ void BruteForceMatcherTest::run( int )
}
}
vector<int> matches;
BruteForceMatcher<L2<float> > matcher;
matcher.add( train );
matcher.match( query, matches );
vector<int> specMatches, genericMatches;
BruteForceMatcher<L2<float> > specMatcher;
BruteForceMatcher<L2Fake > genericMatcher;
specMatcher.add( train );
genericMatcher.add( train );
int64 time0 = cvGetTickCount();
specMatcher.match( query, specMatches );
int64 time1 = cvGetTickCount();
genericMatcher.match( query, genericMatches );
int64 time2 = cvGetTickCount();
float specMatcherTime = float(time1 - time0)/(float)cvGetTickFrequency();
ts->printf( CvTS::LOG, "Matching by matrix multiplication time s: %f, us per pair: %f\n",
specMatcherTime*1e-6, specMatcherTime/( descriptorsNumber*descriptorsNumber ) );
float genericMatcherTime = float(time2 - time1)/(float)cvGetTickFrequency();
ts->printf( CvTS::LOG, "Matching without matrix multiplication time s: %f, us per pair: %f\n",
genericMatcherTime*1e-6, genericMatcherTime/( descriptorsNumber*descriptorsNumber ) );
if( specMatches.size() != descriptorsNumber || genericMatches.size() != descriptorsNumber )
ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );
for( int i=0;i<descriptorsNumber;i++ )
{
if( matches[i] != permutation.at<int>( 0, i ) )
if( specMatches[i] != permutation.at<int>( 0, i ) || genericMatches[i] != permutation.at<int>( 0, i ) )
{
ts->set_failed_test_info( CvTS::FAIL_MISMATCH );
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment