added initializers into GPU perf. tests

This commit is contained in:
Alexey Spizhevoy
2011-01-25 14:43:54 +00:00
parent dbff16eb85
commit 6f91a29ea2
3 changed files with 68 additions and 36 deletions

View File

@@ -7,16 +7,13 @@
#include <string>
#include <opencv2/core/core.hpp>
class Test
class Runnable
{
public:
explicit Test(const std::string& name): name_(name) {}
explicit Runnable(const std::string& name): name_(name) {}
const std::string& name() const { return name_; }
void gen(cv::Mat& mat, int rows, int cols, int type,
cv::Scalar low, cv::Scalar high);
virtual void run() = 0;
private:
@@ -33,7 +30,8 @@ public:
return &me;
}
void add(Test* test) { tests_.push_back(test); }
void addInit(Runnable* init) { inits_.push_back(init); }
void addTest(Runnable* test) { tests_.push_back(test); }
void run();
@@ -58,7 +56,7 @@ public:
// Ends current subtest and starts new one
std::stringstream& subtest()
{
flush();
flush_subtest_data();
return description_;
}
@@ -66,9 +64,10 @@ private:
TestSystem(): can_flush_(false), cpu_elapsed_(0), gpu_elapsed_(0),
speedup_total_(0.0), num_subtests_called_(0) {};
void flush();
void flush_subtest_data();
std::vector<Test*> tests_;
std::vector<Runnable*> inits_;
std::vector<Runnable*> tests_;
// Current test (subtest) description
std::stringstream description_;
@@ -84,14 +83,27 @@ private:
#define TEST(name) \
struct name##_test: Test \
struct name##_test: Runnable \
{ \
name##_test(): Test(#name) { TestSystem::instance()->add(this); } \
name##_test(): Runnable(#name) { \
TestSystem::instance()->addTest(this); \
} \
void run(); \
} name##_test_instance; \
void name##_test::run()
#define INIT(name) \
struct name##_init: Runnable \
{ \
name##_init(): Runnable(#name) { \
TestSystem::instance()->addInit(this); \
} \
void run(); \
} name##_init_instance; \
void name##_init::run()
#define CPU_ON TestSystem::instance()->cpuOn()
#define GPU_ON TestSystem::instance()->gpuOn()
#define CPU_OFF TestSystem::instance()->cpuOff()
@@ -99,4 +111,7 @@ private:
#define SUBTEST TestSystem::instance()->subtest()
#define DESCRIPTION TestSystem::instance()->subtest()
void gen(cv::Mat& mat, int rows, int cols, int type, cv::Scalar low,
cv::Scalar high);
#endif // OPENCV_GPU_SAMPLE_PERFORMANCE_H_