2017-01-30 11:01:45 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
#include <QElapsedTimer.h>
|
2017-01-30 15:00:14 +00:00
|
|
|
#include <QString>
|
2017-01-30 11:01:45 +00:00
|
|
|
#include <iostream>
|
2017-01-30 15:00:14 +00:00
|
|
|
#define TIC(val) Profiler::getInstance().startTimer(val);
|
|
|
|
#define TOC(val) Profiler::getInstance().takeTime(val);
|
2017-01-30 11:01:45 +00:00
|
|
|
|
|
|
|
class Profiler
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
Profiler() { timer.start(); };
|
|
|
|
|
|
|
|
QElapsedTimer timer;
|
|
|
|
|
|
|
|
public:
|
|
|
|
~Profiler() {};
|
|
|
|
|
|
|
|
static Profiler& getInstance() {
|
|
|
|
static Profiler instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2017-01-30 15:00:14 +00:00
|
|
|
void startTimer(QString position = "") {
|
|
|
|
std::cout << "from: " << position.toStdString() << std::endl;
|
2017-01-30 11:01:45 +00:00
|
|
|
timer.restart();
|
|
|
|
};
|
|
|
|
|
2017-01-30 15:00:14 +00:00
|
|
|
void takeTime(QString position = "") {
|
|
|
|
std::cout << "to: "<< position.toStdString() << " time elapsed: " << timer.elapsed() << std::endl;
|
2017-01-30 11:01:45 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
#else
|
2017-01-30 15:00:14 +00:00
|
|
|
#define TIC(val)
|
|
|
|
#define TOC(val)
|
2017-01-30 11:01:45 +00:00
|
|
|
#endif
|