diff --git a/app/common/CMakeLists.txt b/app/common/CMakeLists.txt index 1d123450b..743df6778 100644 --- a/app/common/CMakeLists.txt +++ b/app/common/CMakeLists.txt @@ -29,6 +29,7 @@ set(OLIVE_SOURCES common/filefunctions.cpp common/flipmodifiers.h common/flipmodifiers.cpp + common/functiontimer.h common/lerp.h common/qtutils.h common/qtutils.cpp diff --git a/app/common/functiontimer.h b/app/common/functiontimer.h new file mode 100644 index 000000000..119aecd1d --- /dev/null +++ b/app/common/functiontimer.h @@ -0,0 +1,33 @@ +#ifndef FUNCTIONTIMER_H +#define FUNCTIONTIMER_H + +#include +#include + +#define TIME_THIS_FUNCTION FunctionTimer __f(__FUNCTION__) + +class FunctionTimer { +public: + FunctionTimer(const char* s) + { + name_ = s; + time_ = QDateTime::currentMSecsSinceEpoch(); + } + + ~FunctionTimer() + { + qint64 elapsed = (QDateTime::currentMSecsSinceEpoch() - time_); + + if (elapsed > 1) { + qDebug() << name_ << "took" << elapsed; + } + } + +private: + const char* name_; + + qint64 time_; + +}; + +#endif // FUNCTIONTIMER_H