summaryrefslogtreecommitdiffstats
path: root/kit
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2020-12-06 22:45:46 -0500
committerMichael Meeks <michael.meeks@collabora.com>2020-12-08 09:26:41 +0000
commitba4e52e7b9722f18379d30954a94e95d00c84d3e (patch)
treec6418d904dbcc0937523a4d995a1cbecf52a209e /kit
parentwsd: use steady_clock for measuring time interval (diff)
downloadonline-ba4e52e7b9722f18379d30954a94e95d00c84d3e.tar.gz
online-ba4e52e7b9722f18379d30954a94e95d00c84d3e.zip
wsd: log: overload chrono duration to simplify logging
Also, makes the logging of units much less error prone. The overloaded streaming operators are temporary as they are provided in C++20. The ones here (though incomplete) are fashioned after the C++20 specs. Change-Id: Ieb499282ccb6e63fa939ba07bed3e5a4fbef1bd0 Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Diffstat (limited to 'kit')
-rw-r--r--kit/ChildSession.cpp16
-rw-r--r--kit/Kit.cpp16
2 files changed, 16 insertions, 16 deletions
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index b2b643143b..dbdb9868e9 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -125,7 +125,7 @@ bool ChildSession::_handleInput(const char *buffer, int length)
if (tokens.size() > 0 && tokens.equals(0, "useractive") && getLOKitDocument() != nullptr)
{
- LOG_DBG("Handling message after inactivity of " << getInactivityMS() << "ms.");
+ LOG_DBG("Handling message after inactivity of " << getInactivityMS());
setIsActive(true);
// Client is getting active again.
@@ -734,8 +734,8 @@ bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, con
ptrFont = getLOKitDocument()->renderFont(decodedFont.c_str(), decodedChar.c_str(), &width, &height);
const auto duration = std::chrono::steady_clock::now() - start;
- const auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
- LOG_TRC("renderFont [" << font << "] rendered in " << elapsed << "ms");
+ const auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
+ LOG_TRC("renderFont [" << font << "] rendered in " << elapsed);
if (!ptrFont)
{
@@ -1650,13 +1650,13 @@ bool ChildSession::renderWindow(const char* /*buffer*/, int /*length*/, const St
_viewId);
const double area = width * height;
- const auto elapsedMics = std::chrono::duration_cast<std::chrono::microseconds>(
- std::chrono::steady_clock::now() - start)
- .count();
+ const auto elapsedMs = std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::steady_clock::now() - start);
+ const double elapsedMics = elapsedMs.count() * 1000.; // Need MPixels/second, use Pixels/mics.
LOG_TRC("paintWindow for " << winId << " returned " << width << "X" << height << "@(" << startX
<< ',' << startY << ',' << " with dpi scale: " << dpiScale
- << " and rendered in " << elapsedMics / 1000. << "ms ("
- << area / elapsedMics << " MP/s).");
+ << " and rendered in " << elapsedMs << " (" << area / elapsedMics
+ << " MP/s).");
std::string response = "windowpaint: id=" + tokens[1] + " width=" + std::to_string(width)
+ " height=" + std::to_string(height);
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 7e812207aa..024ecf63e8 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1198,8 +1198,9 @@ private:
_loKitDocumentForAndroidOnly = _loKitDocument;
#endif
const auto duration = std::chrono::steady_clock::now() - start;
- const auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
- LOG_DBG("Returned lokit::documentLoad(" << FileUtil::anonymizeUrl(pURL) << ") in " << elapsed << "ms.");
+ const auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(duration);
+ LOG_DBG("Returned lokit::documentLoad(" << FileUtil::anonymizeUrl(pURL) << ") in "
+ << elapsed);
#ifdef IOS
getDocumentDataForMobileAppDocId(_mobileAppDocId).loKitDocument = _loKitDocument.get();
#endif
@@ -2262,9 +2263,8 @@ void lokit_main(
::setenv("HOME", HomePathInJail, 1);
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
- std::chrono::steady_clock::now() - jailSetupStartTime)
- .count();
- LOG_DBG("Initialized jail files in " << ms << " ms.");
+ std::chrono::steady_clock::now() - jailSetupStartTime);
+ LOG_DBG("Initialized jail files in " << ms);
ProcSMapsFile = open("/proc/self/smaps", O_RDONLY);
if (ProcSMapsFile < 0)
@@ -2611,9 +2611,9 @@ bool globalPreinit(const std::string &loTemplate)
return false;
}
- LOG_TRC("Finished lok_preinit(" << loTemplate << "/program\", \"file:///tmp/user\") in " <<
- std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count() <<
- " ms.");
+ LOG_TRC("Finished lok_preinit(" << loTemplate << "/program\", \"file:///tmp/user\") in "
+ << std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::steady_clock::now() - start));
return true;
}