mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
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 currentIter;
|
||||
unsigned int runsPerIteration;
|
||||
|
||||
performance_metrics metrics;
|
||||
void validateMetrics();
|
||||
@ -307,6 +308,7 @@ private:
|
||||
_declareHelper& iterations(unsigned int n);
|
||||
_declareHelper& time(double timeLimitSecs);
|
||||
_declareHelper& tbb_threads(int n = -1);
|
||||
_declareHelper& runs(unsigned int runsNumber);
|
||||
private:
|
||||
TestBase* test;
|
||||
_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() for(; startTimer(), next(); stopTimer())
|
||||
#define TEST_CYCLE_MULTIRUN(runsNum) for(declare.runs(runsNum); startTimer(), next(); stopTimer()) for(int r = 0; r < runsNum; ++r)
|
||||
|
||||
//flags
|
||||
namespace perf
|
||||
|
@ -731,7 +731,7 @@ performance_metrics& TestBase::calcMetrics()
|
||||
int n = 0;
|
||||
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;
|
||||
double lx = log(x);
|
||||
|
||||
@ -751,14 +751,14 @@ performance_metrics& TestBase::calcMetrics()
|
||||
int offset = 0;
|
||||
if (gstddev > DBL_EPSILON)
|
||||
{
|
||||
double minout = exp(gmean - 3 * gstddev);
|
||||
double maxout = exp(gmean + 3 * gstddev);
|
||||
double minout = exp(gmean - 3 * gstddev) * runsPerIteration;
|
||||
double maxout = exp(gmean + 3 * gstddev) * runsPerIteration;
|
||||
while(*start < minout) ++start, ++metrics.outliers, ++offset;
|
||||
do --end, ++metrics.outliers; while(*end > maxout);
|
||||
++end, --metrics.outliers;
|
||||
}
|
||||
|
||||
metrics.min = (double)*start;
|
||||
metrics.min = static_cast<double>(*start)/runsPerIteration;
|
||||
//calc final metrics
|
||||
n = 0;
|
||||
gmean = 0;
|
||||
@ -768,7 +768,7 @@ performance_metrics& TestBase::calcMetrics()
|
||||
int m = 0;
|
||||
for(; start != end; ++start)
|
||||
{
|
||||
double x = (double)*start;
|
||||
double x = static_cast<double>(*start)/runsPerIteration;
|
||||
if (x > DBL_EPSILON)
|
||||
{
|
||||
double lx = log(x);
|
||||
@ -791,6 +791,8 @@ performance_metrics& TestBase::calcMetrics()
|
||||
? (double)times[offset + n / 2]
|
||||
: 0.5 * (times[offset + n / 2] + times[offset + n / 2 - 1]);
|
||||
|
||||
metrics.median /= runsPerIteration;
|
||||
|
||||
return metrics;
|
||||
}
|
||||
|
||||
@ -902,6 +904,7 @@ void TestBase::SetUp()
|
||||
#endif
|
||||
lastTime = 0;
|
||||
totalTime = 0;
|
||||
runsPerIteration = 1;
|
||||
nIters = iterationsLimitDefault;
|
||||
currentIter = (unsigned int)-1;
|
||||
timeLimit = timeLimitDefault;
|
||||
@ -1023,6 +1026,12 @@ TestBase::_declareHelper& TestBase::_declareHelper::tbb_threads(int n)
|
||||
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)
|
||||
{
|
||||
if (!test->times.empty()) return *this;
|
||||
|
Loading…
Reference in New Issue
Block a user