37 lines
565 B
C++
37 lines
565 B
C++
#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
|