added SURF perf. test, added working dir field (can be changed via CMD args)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <iomanip>
|
||||
#include <stdexcept>
|
||||
#include "performance.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -25,8 +26,14 @@ void TestSystem::run()
|
||||
(*it)->run();
|
||||
flushSubtestData();
|
||||
}
|
||||
catch (const cv::Exception&)
|
||||
catch (const Exception&)
|
||||
{
|
||||
// Message is printed via callback
|
||||
resetSubtestData();
|
||||
}
|
||||
catch (const runtime_error& e)
|
||||
{
|
||||
printError(e.what());
|
||||
resetSubtestData();
|
||||
}
|
||||
}
|
||||
@@ -35,6 +42,12 @@ void TestSystem::run()
|
||||
}
|
||||
|
||||
|
||||
void TestSystem::setWorkingDir(const string& val)
|
||||
{
|
||||
working_dir_ = val;
|
||||
}
|
||||
|
||||
|
||||
void TestSystem::flushSubtestData()
|
||||
{
|
||||
if (!can_flush_)
|
||||
@@ -43,7 +56,7 @@ void TestSystem::flushSubtestData()
|
||||
int cpu_time = static_cast<int>(cpu_elapsed_ / getTickFrequency() * 1000.0);
|
||||
int gpu_time = static_cast<int>(gpu_elapsed_ / getTickFrequency() * 1000.0);
|
||||
|
||||
double speedup = static_cast<double>(cpu_time) / std::max(1, gpu_time);
|
||||
double speedup = static_cast<double>(cpu_elapsed_) / gpu_elapsed_;
|
||||
speedup_total_ += speedup;
|
||||
|
||||
printItem(cpu_time, gpu_time, speedup);
|
||||
@@ -57,7 +70,7 @@ void TestSystem::printHeading()
|
||||
{
|
||||
cout << setiosflags(ios_base::left);
|
||||
cout << TAB << setw(10) << "CPU, ms" << setw(10) << "GPU, ms"
|
||||
<< setw(10) << "SPEEDUP"
|
||||
<< setw(14) << "SPEEDUP"
|
||||
<< "DESCRIPTION\n";
|
||||
cout << resetiosflags(ios_base::left);
|
||||
}
|
||||
@@ -87,13 +100,19 @@ void TestSystem::printItem(double cpu_time, double gpu_time, double speedup)
|
||||
|
||||
stream.str("");
|
||||
stream << "x" << setprecision(3) << speedup;
|
||||
cout << setw(10) << stream.str();
|
||||
cout << setw(14) << stream.str();
|
||||
|
||||
cout << description_.str();
|
||||
cout << resetiosflags(ios_base::left) << endl;
|
||||
}
|
||||
|
||||
|
||||
void TestSystem::printError(const std::string& msg)
|
||||
{
|
||||
cout << TAB << "[error: " << msg << "] " << description_.str() << endl;
|
||||
}
|
||||
|
||||
|
||||
void gen(Mat& mat, int rows, int cols, int type, Scalar low, Scalar high)
|
||||
{
|
||||
mat.create(rows, cols, type);
|
||||
@@ -102,17 +121,34 @@ void gen(Mat& mat, int rows, int cols, int type, Scalar low, Scalar high)
|
||||
}
|
||||
|
||||
|
||||
string abspath(const string& relpath)
|
||||
{
|
||||
return TestSystem::instance()->workingDir() + relpath;
|
||||
}
|
||||
|
||||
|
||||
int CV_CDECL cvErrorCallback(int /*status*/, const char* /*func_name*/,
|
||||
const char* /*err_msg*/, const char* /*file_name*/,
|
||||
const char* err_msg, const char* /*file_name*/,
|
||||
int /*line*/, void* /*userdata*/)
|
||||
{
|
||||
TestSystem::instance()->printError(err_msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
cout << "Usage: performance_gpu <working_dir_with_slash>\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
TestSystem::instance()->setWorkingDir(argv[1]);
|
||||
}
|
||||
|
||||
redirectError(cvErrorCallback);
|
||||
TestSystem::instance()->run();
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user