added Profiler to analyses the time used by code lines
This commit is contained in:
36
QtMeshViewer/Header/Profiler.h
Normal file
36
QtMeshViewer/Header/Profiler.h
Normal 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
|
Reference in New Issue
Block a user