[Libreoffice-commits] online.git: kit/ChildSession.cpp kit/Kit.cpp test/UnitPrefork.cpp

DarkByt31 (via logerrit) logerrit at kemper.freedesktop.org
Sat Sep 28 10:51:38 UTC 2019


 kit/ChildSession.cpp |   17 +++++++++++------
 kit/Kit.cpp          |   22 ++++++++++++++--------
 test/UnitPrefork.cpp |    7 ++++---
 3 files changed, 29 insertions(+), 17 deletions(-)

New commits:
commit ef90709ad1cb6c8cbb649425d0f0c539bbd5f83f
Author:     DarkByt31 <avihs.29 at gmail.com>
AuthorDate: Sun Sep 15 07:34:06 2019 +0530
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Sat Sep 28 12:51:18 2019 +0200

    tdf#107038 Poco::Timestamp replacement with std::chrono
    
    Change-Id: I55ba23fb104a90c882bc2af068b835e30877bc1e
    Reviewed-on: https://gerrit.libreoffice.org/78925
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index b201e4d34..1f4ea15a5 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -46,7 +46,6 @@
 using Poco::JSON::Object;
 using Poco::JSON::Parser;
 using Poco::StringTokenizer;
-using Poco::Timestamp;
 using Poco::URI;
 
 using namespace LOOLProtocol;
@@ -662,7 +661,7 @@ bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, con
     output.resize(response.size());
     std::memcpy(output.data(), response.data(), response.size());
 
-    Timestamp timestamp;
+    const auto start = std::chrono::system_clock::now();
     // renderFont use a default font size (25) when width and height are 0
     int width = 0, height = 0;
     unsigned char* ptrFont = nullptr;
@@ -671,7 +670,9 @@ bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, con
 
     ptrFont = getLOKitDocument()->renderFont(decodedFont.c_str(), decodedChar.c_str(), &width, &height);
 
-    LOG_TRC("renderFont [" << font << "] rendered in " << (timestamp.elapsed()/1000.) << "ms");
+    const auto duration = std::chrono::system_clock::now() - start;
+    const auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
+    LOG_TRC("renderFont [" << font << "] rendered in " << elapsed << "ms");
 
     if (!ptrFont)
     {
@@ -1457,14 +1458,18 @@ bool ChildSession::renderWindow(const char* /*buffer*/, int /*length*/, const st
     std::vector<unsigned char> pixmap(pixmapDataSize);
     int width = bufferWidth, height = bufferHeight;
     std::string response;
-    Timestamp timestamp;
+    const auto start = std::chrono::system_clock::now();
     getLOKitDocument()->paintWindow(winId, pixmap.data(), startX, startY, width, height, dpiScale);
     const double area = width * height;
+
+    const auto duration = std::chrono::system_clock::now() - start;
+    const auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
+    const double totalTime = elapsed/1000.;
     LOG_TRC("paintWindow for " << winId << " returned " << width << "X" << height
             << "@(" << startX << "," << startY << ")"
             << " with dpi scale: " << dpiScale
-            << " and rendered in " << (timestamp.elapsed()/1000.)
-            << "ms (" << area / (timestamp.elapsed()) << " MP/s).");
+            << " and rendered in " << totalTime
+            << "ms (" << area / elapsed << " MP/s).");
 
     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 b2a4a8b23..0dd75ff7b 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -97,7 +97,6 @@ using Poco::JSON::Object;
 using Poco::JSON::Parser;
 using Poco::StringTokenizer;
 using Poco::Thread;
-using Poco::Timestamp;
 using Poco::URI;
 using Poco::Util::Application;
 
@@ -1119,17 +1118,19 @@ public:
 
         // Render the whole area
         const double area = pixmapWidth * pixmapHeight;
-        Timestamp timestamp;
+        auto start = std::chrono::system_clock::now();
         LOG_TRC("Calling paintPartTile(" << (void*)pixmap.data() << ")");
         _loKitDocument->paintPartTile(pixmap.data(),
                                       tileCombined.getPart(),
                                       pixmapWidth, pixmapHeight,
                                       renderArea.getLeft(), renderArea.getTop(),
                                       renderArea.getWidth(), renderArea.getHeight());
-        Timestamp::TimeDiff elapsed = timestamp.elapsed();
+        auto duration = std::chrono::system_clock::now() - start;
+        auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
+        double totalTime = elapsed/1000.;
         LOG_DBG("paintTile (combined) at (" << renderArea.getLeft() << ", " << renderArea.getTop() << "), (" <<
                 renderArea.getWidth() << ", " << renderArea.getHeight() << ") " <<
-                " rendered in " << (elapsed/1000.) << " ms (" << area / elapsed << " MP/s).");
+                " rendered in " << totalTime << " ms (" << area / elapsed << " MP/s).");
         const auto mode = static_cast<LibreOfficeKitTileMode>(_loKitDocument->getTileMode());
 
         std::vector<char> output;
@@ -1267,10 +1268,12 @@ public:
 
         _pngCache.balanceCache();
 
-        elapsed = timestamp.elapsed();
+        duration = std::chrono::system_clock::now() - start;
+        elapsed = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
+        totalTime = elapsed/1000.;
         LOG_DBG("renderCombinedTiles at (" << renderArea.getLeft() << ", " << renderArea.getTop() << "), (" <<
                 renderArea.getWidth() << ", " << renderArea.getHeight() << ") " <<
-                " took " << (elapsed/1000.) << " ms (including the paintTile).");
+                " took " << totalTime << " ms (including the paintTile).");
 
         if (tileIndex == 0)
         {
@@ -1766,9 +1769,12 @@ private:
             _isDocPasswordProtected = false;
 
             LOG_DBG("Calling lokit::documentLoad(" << uriAnonym << ", \"" << options << "\").");
-            Timestamp timestamp;
+            const auto start = std::chrono::system_clock::now();
             _loKitDocument.reset(_loKit->documentLoad(docTemplate.empty() ? uri.c_str() : docTemplate.c_str(), options.c_str()));
-            LOG_DBG("Returned lokit::documentLoad(" << uriAnonym << ") in " << (timestamp.elapsed() / 1000.) << "ms.");
+            const auto duration = std::chrono::system_clock::now() - start;
+            const auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
+            const double totalTime = elapsed/1000.;
+            LOG_DBG("Returned lokit::documentLoad(" << uriAnonym << ") in " << totalTime << "ms.");
 #ifdef IOS
             // The iOS app (and the Android one) has max one document open at a time, so we can keep
             // a pointer to it in a global.
diff --git a/test/UnitPrefork.cpp b/test/UnitPrefork.cpp
index 827e1c062..4f22ffb77 100644
--- a/test/UnitPrefork.cpp
+++ b/test/UnitPrefork.cpp
@@ -17,7 +17,7 @@ const int NumToPrefork = 20;
 // Inside the WSD process
 class UnitPrefork : public UnitWSD
 {
-    Poco::Timestamp _startTime;
+    std::chrono::system_clock::time_point _startTime = std::chrono::system_clock::now();
     std::atomic< int > _childSockets;
 
 public:
@@ -40,9 +40,10 @@ public:
 
         if (_childSockets >= NumToPrefork)
         {
-            Poco::Timestamp::TimeDiff elapsed = _startTime.elapsed();
+            const auto duration = std::chrono::system_clock::now() - _startTime;
+            const auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
+            const double totalTime = elapsed/1000.;
 
-            const double totalTime = (1000. * elapsed)/Poco::Timestamp::resolution();
             LOG_INF("Launched " << _childSockets << " in " << totalTime);
             std::cerr << "Launch time total   " << totalTime << " ms" << std::endl;
             std::cerr << "Launch time average " << (totalTime / _childSockets) << " ms" << std::endl;


More information about the Libreoffice-commits mailing list