added Profiler to analyses the time used by code lines

This commit is contained in:
Anakin 2017-01-30 12:01:45 +01:00
parent 9c16aa32f1
commit d1c68e8ba6
3 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,36 @@
#pragma once
#ifdef _DEBUG
#include <QElapsedTimer.h>
#include <iostream>
#define TIC Profiler::getInstance().startTimer();
#define TOC Profiler::getInstance().takeTime();
class Profiler
{
private:
Profiler() { timer.start(); };
QElapsedTimer timer;
public:
~Profiler() {};
static Profiler& getInstance() {
static Profiler instance;
return instance;
}
void startTimer() {
timer.restart();
};
void takeTime() {
std::cout << "time elapsed: " << timer.elapsed() << std::endl;
};
};
#else
#define TIC
#define TOC
#endif

View File

@ -5,6 +5,7 @@
#include "..\Header\OutputDevice.h"
#include <QRegExp>
#include "../Header/Profiler.h"
/////////////////////////////////////////////////////////////////////////
// constructor/destructor

View File

@ -4,6 +4,8 @@
#include <QDropEvent>
#include <QMimeData>
#include "..\Header\Profiler.h"
#define DEFAULT_Z_DISTANCE -4.0