2017-10-08 17:23:46 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QElapsedTimer>
|
2017-10-11 10:34:04 +02:00
|
|
|
#include <boost/current_function.hpp>
|
2018-05-24 22:58:07 +02:00
|
|
|
#include <boost/noncopyable.hpp>
|
2017-10-08 17:23:46 +02:00
|
|
|
|
|
|
|
#define BENCH(x) \
|
|
|
|
QElapsedTimer x; \
|
|
|
|
x.start();
|
|
|
|
|
2017-10-11 10:34:04 +02:00
|
|
|
#define MARK(x) \
|
|
|
|
qDebug() << BOOST_CURRENT_FUNCTION << __LINE__ \
|
|
|
|
<< static_cast<float>(x.nsecsElapsed()) / 100000.0 << "ms";
|
2018-05-24 22:58:07 +02:00
|
|
|
|
|
|
|
class BenchmarkGuard : boost::noncopyable {
|
|
|
|
QElapsedTimer timer;
|
|
|
|
QString name;
|
|
|
|
|
|
|
|
public:
|
|
|
|
BenchmarkGuard(const QString &_name)
|
|
|
|
:name(_name)
|
|
|
|
{
|
|
|
|
timer.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
~BenchmarkGuard() {
|
|
|
|
qDebug() << this->name << float(timer.nsecsElapsed()) / 100000.0 << "ms";
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal getElapsedMs() {
|
|
|
|
return qreal(timer.nsecsElapsed()) / 100000.0;
|
|
|
|
}
|
|
|
|
};
|