From de24cdc12cb1f8791067c4b7a773e14694ac6d03 Mon Sep 17 00:00:00 2001 From: elsid Date: Wed, 15 Feb 2023 20:56:32 +0100 Subject: [PATCH] Log content files loading time by editor --- apps/opencs/model/doc/loader.cpp | 12 ++++++++++++ apps/opencs/model/doc/loader.hpp | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/apps/opencs/model/doc/loader.cpp b/apps/opencs/model/doc/loader.cpp index 0a9937d4a5..d3a3490f73 100644 --- a/apps/opencs/model/doc/loader.cpp +++ b/apps/opencs/model/doc/loader.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -56,6 +57,9 @@ void CSMDoc::Loader::load() return; } + if (!mStart.has_value()) + mStart = std::chrono::steady_clock::now(); + std::vector>::iterator iter = mDocuments.begin(); Document* document = iter->first; @@ -133,6 +137,14 @@ void CSMDoc::Loader::load() if (done) { + if (mStart.has_value()) + { + const auto duration = std::chrono::steady_clock::now() - *mStart; + Log(Debug::Verbose) << "Loaded content files in " + << std::chrono::duration_cast>(duration).count() << 's'; + mStart.reset(); + } + mDocuments.erase(iter); emit documentLoaded(document); } diff --git a/apps/opencs/model/doc/loader.hpp b/apps/opencs/model/doc/loader.hpp index 56240a91e0..ccf493d19e 100644 --- a/apps/opencs/model/doc/loader.hpp +++ b/apps/opencs/model/doc/loader.hpp @@ -1,6 +1,8 @@ #ifndef CSM_DOC_LOADER_H #define CSM_DOC_LOADER_H +#include +#include #include #include #include @@ -35,6 +37,8 @@ namespace CSMDoc QTimer* mTimer; bool mShouldStop; + std::optional mStart; + public: Loader();