perf_framework: added TEST_CYCLE_MULTIRUN macros ( invokes function tested several times at each iteration )
This commit is contained in:
parent
276a3fe01b
commit
6455488ff4
@ -279,6 +279,7 @@ private:
|
|||||||
|
|
||||||
unsigned int nIters;
|
unsigned int nIters;
|
||||||
unsigned int currentIter;
|
unsigned int currentIter;
|
||||||
|
unsigned int runsPerIteration;
|
||||||
|
|
||||||
performance_metrics metrics;
|
performance_metrics metrics;
|
||||||
void validateMetrics();
|
void validateMetrics();
|
||||||
@ -307,6 +308,7 @@ private:
|
|||||||
_declareHelper& iterations(unsigned int n);
|
_declareHelper& iterations(unsigned int n);
|
||||||
_declareHelper& time(double timeLimitSecs);
|
_declareHelper& time(double timeLimitSecs);
|
||||||
_declareHelper& tbb_threads(int n = -1);
|
_declareHelper& tbb_threads(int n = -1);
|
||||||
|
_declareHelper& runs(unsigned int runsNumber);
|
||||||
private:
|
private:
|
||||||
TestBase* test;
|
TestBase* test;
|
||||||
_declareHelper(TestBase* t);
|
_declareHelper(TestBase* t);
|
||||||
@ -460,6 +462,7 @@ int main(int argc, char **argv)\
|
|||||||
|
|
||||||
#define TEST_CYCLE_N(n) for(declare.iterations(n); startTimer(), next(); stopTimer())
|
#define TEST_CYCLE_N(n) for(declare.iterations(n); startTimer(), next(); stopTimer())
|
||||||
#define TEST_CYCLE() for(; startTimer(), next(); stopTimer())
|
#define TEST_CYCLE() for(; startTimer(), next(); stopTimer())
|
||||||
|
#define TEST_CYCLE_MULTIRUN(runsNum) for(declare.runs(runsNum); startTimer(), next(); stopTimer()) for(int r = 0; r < runsNum; ++r)
|
||||||
|
|
||||||
//flags
|
//flags
|
||||||
namespace perf
|
namespace perf
|
||||||
|
@ -731,7 +731,7 @@ performance_metrics& TestBase::calcMetrics()
|
|||||||
int n = 0;
|
int n = 0;
|
||||||
for(TimeVector::const_iterator i = times.begin(); i != times.end(); ++i)
|
for(TimeVector::const_iterator i = times.begin(); i != times.end(); ++i)
|
||||||
{
|
{
|
||||||
double x = (double)*i;
|
double x = static_cast<double>(*i)/runsPerIteration;
|
||||||
if (x < DBL_EPSILON) continue;
|
if (x < DBL_EPSILON) continue;
|
||||||
double lx = log(x);
|
double lx = log(x);
|
||||||
|
|
||||||
@ -751,14 +751,14 @@ performance_metrics& TestBase::calcMetrics()
|
|||||||
int offset = 0;
|
int offset = 0;
|
||||||
if (gstddev > DBL_EPSILON)
|
if (gstddev > DBL_EPSILON)
|
||||||
{
|
{
|
||||||
double minout = exp(gmean - 3 * gstddev);
|
double minout = exp(gmean - 3 * gstddev) * runsPerIteration;
|
||||||
double maxout = exp(gmean + 3 * gstddev);
|
double maxout = exp(gmean + 3 * gstddev) * runsPerIteration;
|
||||||
while(*start < minout) ++start, ++metrics.outliers, ++offset;
|
while(*start < minout) ++start, ++metrics.outliers, ++offset;
|
||||||
do --end, ++metrics.outliers; while(*end > maxout);
|
do --end, ++metrics.outliers; while(*end > maxout);
|
||||||
++end, --metrics.outliers;
|
++end, --metrics.outliers;
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics.min = (double)*start;
|
metrics.min = static_cast<double>(*start)/runsPerIteration;
|
||||||
//calc final metrics
|
//calc final metrics
|
||||||
n = 0;
|
n = 0;
|
||||||
gmean = 0;
|
gmean = 0;
|
||||||
@ -768,7 +768,7 @@ performance_metrics& TestBase::calcMetrics()
|
|||||||
int m = 0;
|
int m = 0;
|
||||||
for(; start != end; ++start)
|
for(; start != end; ++start)
|
||||||
{
|
{
|
||||||
double x = (double)*start;
|
double x = static_cast<double>(*start)/runsPerIteration;
|
||||||
if (x > DBL_EPSILON)
|
if (x > DBL_EPSILON)
|
||||||
{
|
{
|
||||||
double lx = log(x);
|
double lx = log(x);
|
||||||
@ -791,6 +791,8 @@ performance_metrics& TestBase::calcMetrics()
|
|||||||
? (double)times[offset + n / 2]
|
? (double)times[offset + n / 2]
|
||||||
: 0.5 * (times[offset + n / 2] + times[offset + n / 2 - 1]);
|
: 0.5 * (times[offset + n / 2] + times[offset + n / 2 - 1]);
|
||||||
|
|
||||||
|
metrics.median /= runsPerIteration;
|
||||||
|
|
||||||
return metrics;
|
return metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -902,6 +904,7 @@ void TestBase::SetUp()
|
|||||||
#endif
|
#endif
|
||||||
lastTime = 0;
|
lastTime = 0;
|
||||||
totalTime = 0;
|
totalTime = 0;
|
||||||
|
runsPerIteration = 1;
|
||||||
nIters = iterationsLimitDefault;
|
nIters = iterationsLimitDefault;
|
||||||
currentIter = (unsigned int)-1;
|
currentIter = (unsigned int)-1;
|
||||||
timeLimit = timeLimitDefault;
|
timeLimit = timeLimitDefault;
|
||||||
@ -1023,6 +1026,12 @@ TestBase::_declareHelper& TestBase::_declareHelper::tbb_threads(int n)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TestBase::_declareHelper& TestBase::_declareHelper::runs(unsigned int runsNumber)
|
||||||
|
{
|
||||||
|
test->runsPerIteration = runsNumber;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
TestBase::_declareHelper& TestBase::_declareHelper::in(cv::InputOutputArray a1, int wtype)
|
TestBase::_declareHelper& TestBase::_declareHelper::in(cv::InputOutputArray a1, int wtype)
|
||||||
{
|
{
|
||||||
if (!test->times.empty()) return *this;
|
if (!test->times.empty()) return *this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user