mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
ocl: simplify ocl::Timer interface
This commit is contained in:
@@ -742,13 +742,16 @@ public:
|
||||
~Timer();
|
||||
void start();
|
||||
void stop();
|
||||
float milliSeconds();
|
||||
float microSeconds();
|
||||
float seconds();
|
||||
|
||||
uint64 durationNS() const; //< duration in nanoseconds
|
||||
|
||||
protected:
|
||||
struct Impl;
|
||||
Impl* p;
|
||||
Impl* const p;
|
||||
|
||||
private:
|
||||
Timer(const Timer&); // disabled
|
||||
Timer& operator=(const Timer&); // disabled
|
||||
};
|
||||
|
||||
CV_EXPORTS MatAllocator* getOpenCLAllocator();
|
||||
|
||||
+14
-45
@@ -5288,68 +5288,37 @@ struct Timer::Impl
|
||||
#endif
|
||||
}
|
||||
|
||||
float microSeconds()
|
||||
uint64 durationNS() const
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
return (float)timer.getTimeMicro();
|
||||
return (uint64)(timer.getTimeSec() * 1e9);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
float milliSeconds()
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
return (float)timer.getTimeMilli();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
float seconds()
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
return (float)timer.getTimeSec();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
TickMeter timer;
|
||||
};
|
||||
|
||||
Timer::Timer(const Queue& q)
|
||||
{
|
||||
p = new Impl(q);
|
||||
}
|
||||
|
||||
Timer::~Timer()
|
||||
{
|
||||
if(p)
|
||||
{
|
||||
delete p;
|
||||
p = 0;
|
||||
}
|
||||
}
|
||||
Timer::Timer(const Queue& q) : p(new Impl(q)) { }
|
||||
Timer::~Timer() { delete p; }
|
||||
|
||||
void Timer::start()
|
||||
{
|
||||
if(p)
|
||||
p->start();
|
||||
CV_Assert(p);
|
||||
p->start();
|
||||
}
|
||||
|
||||
void Timer::stop()
|
||||
{
|
||||
if(p)
|
||||
p->stop();
|
||||
CV_Assert(p);
|
||||
p->stop();
|
||||
}
|
||||
|
||||
float Timer::microSeconds()
|
||||
{ return p ? p->microSeconds() : 0; }
|
||||
uint64 Timer::durationNS() const
|
||||
{
|
||||
CV_Assert(p);
|
||||
return p->durationNS();
|
||||
}
|
||||
|
||||
float Timer::milliSeconds()
|
||||
{ return p ? p->milliSeconds() : 0; }
|
||||
|
||||
float Timer::seconds()
|
||||
{ return p ? p->seconds() : 0; }
|
||||
|
||||
}}
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user