mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 19:20:28 +08:00
added error handling into GPU perf. tests
This commit is contained in:
parent
6f91a29ea2
commit
ab8f578f9d
@ -12,7 +12,7 @@ void TestSystem::run()
|
|||||||
(*it)->run();
|
(*it)->run();
|
||||||
|
|
||||||
cout << setiosflags(ios_base::left);
|
cout << setiosflags(ios_base::left);
|
||||||
cout << " " << setw(10) << "CPU, ms" << setw(10) << "GPU, ms"
|
cout << TAB << setw(10) << "CPU, ms" << setw(10) << "GPU, ms"
|
||||||
<< setw(10) << "SPEEDUP" << "DESCRIPTION\n";
|
<< setw(10) << "SPEEDUP" << "DESCRIPTION\n";
|
||||||
cout << resetiosflags(ios_base::left);
|
cout << resetiosflags(ios_base::left);
|
||||||
|
|
||||||
@ -21,8 +21,23 @@ void TestSystem::run()
|
|||||||
for (; it != tests_.end(); ++it)
|
for (; it != tests_.end(); ++it)
|
||||||
{
|
{
|
||||||
cout << endl << (*it)->name() << ":\n";
|
cout << endl << (*it)->name() << ":\n";
|
||||||
(*it)->run();
|
try
|
||||||
flush_subtest_data();
|
{
|
||||||
|
(*it)->run();
|
||||||
|
flush_subtest_data();
|
||||||
|
}
|
||||||
|
catch (const cv::Exception& e)
|
||||||
|
{
|
||||||
|
cout << TAB << "error";
|
||||||
|
switch (e.code)
|
||||||
|
{
|
||||||
|
case CV_StsNoMem: cout << ": out of memory"; break;
|
||||||
|
}
|
||||||
|
if (!description_.str().empty())
|
||||||
|
cout << " [" << description_.str() << "]";
|
||||||
|
cout << endl;
|
||||||
|
reset_subtest_data();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << setiosflags(ios_base::fixed | ios_base::left);
|
cout << setiosflags(ios_base::fixed | ios_base::left);
|
||||||
@ -39,13 +54,11 @@ void TestSystem::flush_subtest_data()
|
|||||||
|
|
||||||
int cpu_time = static_cast<int>(cpu_elapsed_ / getTickFrequency() * 1000.0);
|
int cpu_time = static_cast<int>(cpu_elapsed_ / getTickFrequency() * 1000.0);
|
||||||
int gpu_time = static_cast<int>(gpu_elapsed_ / getTickFrequency() * 1000.0);
|
int gpu_time = static_cast<int>(gpu_elapsed_ / getTickFrequency() * 1000.0);
|
||||||
cpu_elapsed_ = 0;
|
|
||||||
gpu_elapsed_ = 0;
|
|
||||||
|
|
||||||
double speedup = static_cast<double>(cpu_time) / std::max(1, gpu_time);
|
double speedup = static_cast<double>(cpu_time) / std::max(1, gpu_time);
|
||||||
speedup_total_ += speedup;
|
speedup_total_ += speedup;
|
||||||
|
|
||||||
cout << " " << setiosflags(ios_base::fixed | ios_base::left);
|
cout << TAB << setiosflags(ios_base::fixed | ios_base::left);
|
||||||
|
|
||||||
stringstream stream;
|
stringstream stream;
|
||||||
stream << cpu_time;
|
stream << cpu_time;
|
||||||
@ -60,12 +73,11 @@ void TestSystem::flush_subtest_data()
|
|||||||
cout << setw(10) << stream.str();
|
cout << setw(10) << stream.str();
|
||||||
|
|
||||||
cout << description_.str();
|
cout << description_.str();
|
||||||
description_.str("");
|
|
||||||
|
|
||||||
cout << resetiosflags(ios_base::fixed | ios_base::left) << endl;
|
cout << resetiosflags(ios_base::fixed | ios_base::left) << endl;
|
||||||
|
|
||||||
can_flush_ = false;
|
|
||||||
num_subtests_called_++;
|
num_subtests_called_++;
|
||||||
|
reset_subtest_data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -77,8 +89,17 @@ void gen(Mat& mat, int rows, int cols, int type, Scalar low, Scalar high)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int CV_CDECL cvErrorCallback(int /*status*/, const char* /*func_name*/,
|
||||||
|
const char* /*err_msg*/, const char* /*file_name*/,
|
||||||
|
int /*line*/, void* /*userdata*/)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
redirectError(cvErrorCallback);
|
||||||
TestSystem::instance()->run();
|
TestSystem::instance()->run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -7,6 +7,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <opencv2/core/core.hpp>
|
#include <opencv2/core/core.hpp>
|
||||||
|
|
||||||
|
#define TAB " "
|
||||||
|
|
||||||
class Runnable
|
class Runnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -31,6 +33,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addInit(Runnable* init) { inits_.push_back(init); }
|
void addInit(Runnable* init) { inits_.push_back(init); }
|
||||||
|
|
||||||
void addTest(Runnable* test) { tests_.push_back(test); }
|
void addTest(Runnable* test) { tests_.push_back(test); }
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
@ -66,6 +69,14 @@ private:
|
|||||||
|
|
||||||
void flush_subtest_data();
|
void flush_subtest_data();
|
||||||
|
|
||||||
|
void reset_subtest_data()
|
||||||
|
{
|
||||||
|
cpu_elapsed_ = 0;
|
||||||
|
gpu_elapsed_ = 0;
|
||||||
|
description_.str("");
|
||||||
|
can_flush_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Runnable*> inits_;
|
std::vector<Runnable*> inits_;
|
||||||
std::vector<Runnable*> tests_;
|
std::vector<Runnable*> tests_;
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ TEST(dft)
|
|||||||
Mat src, dst;
|
Mat src, dst;
|
||||||
gpu::GpuMat d_src, d_dst;
|
gpu::GpuMat d_src, d_dst;
|
||||||
|
|
||||||
for (int size = 1000; size <= 4000; size *= 2)
|
for (int size = 1000; size <= 8000; size *= 2)
|
||||||
{
|
{
|
||||||
SUBTEST << "size " << size << ", 32FC2, complex-to-complex";
|
SUBTEST << "size " << size << ", 32FC2, complex-to-complex";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user