diff --git a/QtMeshViewer/Header/Profiler.h b/QtMeshViewer/Header/Profiler.h new file mode 100644 index 0000000..2ac8645 --- /dev/null +++ b/QtMeshViewer/Header/Profiler.h @@ -0,0 +1,36 @@ +#pragma once + +#ifdef _DEBUG + #include + #include + #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 diff --git a/QtMeshViewer/Source/GeometryEngine.cpp b/QtMeshViewer/Source/GeometryEngine.cpp index 331eaae..a113718 100644 --- a/QtMeshViewer/Source/GeometryEngine.cpp +++ b/QtMeshViewer/Source/GeometryEngine.cpp @@ -5,6 +5,7 @@ #include "..\Header\OutputDevice.h" #include +#include "../Header/Profiler.h" ///////////////////////////////////////////////////////////////////////// // constructor/destructor diff --git a/QtMeshViewer/Source/OglViewerWidget.cpp b/QtMeshViewer/Source/OglViewerWidget.cpp index ea35f65..a780ef7 100644 --- a/QtMeshViewer/Source/OglViewerWidget.cpp +++ b/QtMeshViewer/Source/OglViewerWidget.cpp @@ -4,6 +4,8 @@ #include #include +#include "..\Header\Profiler.h" + #define DEFAULT_Z_DISTANCE -4.0