diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-12-19 19:35:36 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-04 03:33:18 -0500 |
| commit | 2d276cad0b46d68e6886645559cd47c0165392fe (patch) | |
| tree | 9489bd33ac339e688ea4e4a899bf33043a47adf4 /src/shared/util.cpp | |
| parent | a7051df5da4139661169f227861b712453e7b8b0 (diff) | |
put expensive logging in an optional function
Diffstat (limited to 'src/shared/util.cpp')
| -rw-r--r-- | src/shared/util.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/shared/util.cpp b/src/shared/util.cpp index 302dea7d..4ac95465 100644 --- a/src/shared/util.cpp +++ b/src/shared/util.cpp @@ -21,6 +21,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "windows_error.h"
#include "mainwindow.h"
#include "env.h"
+#include <log.h>
#include <usvfs.h>
#include <usvfs_version.h>
@@ -320,6 +321,26 @@ void SetThisThreadName(const QString& s) } // namespace MOShared
+TimeThis::TimeThis(QString what)
+ : m_what(std::move(what)), m_start(Clock::now())
+{
+}
+
+TimeThis::~TimeThis()
+{
+ using namespace std::chrono;
+
+ const auto end = Clock::now();
+ const auto d = duration_cast<milliseconds>(end - m_start).count();
+
+ if (m_what.isEmpty()) {
+ MOBase::log::debug("{} ms", d);
+ } else {
+ MOBase::log::debug("{} {} ms", m_what, d);
+ }
+}
+
+
static bool g_exiting = false;
static bool g_canClose = false;
|
