[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-11-13 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |6 --
 1 file changed, 6 deletions(-)

New commits:
commit 41e0902cdf0fd2ae54616dc1d451aa7ebba78dbb
Author: Ashod Nakashian 
Date:   Sat Nov 12 16:43:17 2016 -0500

loolwsd: cleanup LOOLStress

Change-Id: I8161488d30f8e173db47ccae5544b6d8b9f21f02
Reviewed-on: https://gerrit.libreoffice.org/30821
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index 7dbe7a6..e8e86fc 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -39,10 +39,7 @@
 #include 
 #include 
 
-#include "Common.hpp"
-#include "LOOLProtocol.hpp"
 #include "TraceFile.hpp"
-#include "Util.hpp"
 #include "test/helpers.hpp"
 
 /// Stress testing and performance/scalability benchmarking tool.
@@ -64,9 +61,6 @@ protected:
 int  main(const std::vector& args) override;
 };
 
-
-using namespace LOOLProtocol;
-
 using Poco::Net::HTTPRequest;
 using Poco::Net::HTTPResponse;
 using Poco::Runnable;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-10-04 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit a0f6f4e41cebdc6617ef839c19d274e7ec7012d4
Author: Ashod Nakashian 
Date:   Mon Oct 3 23:43:44 2016 -0400

loolstress: use new URI for loading documents

Change-Id: If811deffc4b7a9b2cf290b93d9f87a840e64dc4e
Reviewed-on: https://gerrit.libreoffice.org/29531
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index c43cfbc..484d3fb 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -110,7 +110,10 @@ public:
 
 // Load a document and get its status.
 std::cout << "NewSession [" << sessionId << "]: " << uri.toString() << 
"... ";
-Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
"/lool/ws/" + documentURL);
+
+std::string encodedUri;
+Poco::URI::encode(documentURL, ":/?", encodedUri);
+Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
"/lool/" + encodedUri + "/ws");
 Poco::Net::HTTPResponse response;
 auto ws = helpers::connectLOKit(uri, request, response, sessionId + ' 
');
 std::cout << "Connected.\n";
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-09-25 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |   49 +
 1 file changed, 29 insertions(+), 20 deletions(-)

New commits:
commit 720f1260a769ff233702d8dbcf850af4a73aef38
Author: Ashod Nakashian 
Date:   Sun Sep 25 11:32:50 2016 -0400

loolstress: more accurate stats and other improvements

Change-Id: Ib4960fa2770ba783eb969c5a356f0bfa01b96dc9
Reviewed-on: https://gerrit.libreoffice.org/29279
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index 2929bee..ffe205f 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -158,6 +158,10 @@ private:
 
 std::mutex Connection::Mutex;
 
+static constexpr auto FIRST_ROW_TILES = "tilecombine part=0 width=256 
height=256 tileposx=0,3840,7680 tileposy=0,0,0 tilewidth=3840 tileheight=3840";
+static constexpr auto FIRST_PAGE_TILES = "tilecombine part=0 width=256 
height=256 
tileposx=0,3840,7680,11520,0,3840,7680,11520,0,3840,7680,11520,0,3840,7680,11520
 
tileposy=0,0,0,0,3840,3840,3840,3840,7680,7680,7680,7680,11520,11520,11520,11520
 tilewidth=3840 tileheight=3840";
+static constexpr auto FIRST_PAGE_TILE_COUNT = 16;
+
 /// Main thread class to replay a trace file.
 class Worker: public Runnable
 {
@@ -201,35 +205,38 @@ private:
 
 bool modifyDoc(const std::shared_ptr& con)
 {
-con->send("key type=input char=97 key=0");
-return !con->recv("invalidatetiles:").empty();
+const auto startModify = std::chrono::steady_clock::now();
+
+con->send("key type=input char=97 key=0");   // a
+//con->send("key type=input char=0 key=1283"); // backspace
+const bool success = !con->recv("invalidatetiles:").empty();
+
+const auto now = std::chrono::steady_clock::now();
+const auto deltaModify = 
std::chrono::duration_cast(now - 
startModify).count();
+_latencyStats.push_back(deltaModify);
+
+return success;
 }
 
 bool renderTile(const std::shared_ptr& con)
 {
-const auto startModify = std::chrono::steady_clock::now();
-
 modifyDoc(con);
 
-const auto startRendering = std::chrono::steady_clock::now();
+const auto start = std::chrono::steady_clock::now();
 
-auto expectedTilesCount = 3;
-con->send("tilecombine part=0 width=256 height=256 
tileposx=0,3840,7680 tileposy=0,0,0 tilewidth=3840 tileheight=3840");
+const auto expectedTilesCount = FIRST_PAGE_TILE_COUNT;
+con->send(FIRST_PAGE_TILES);
 for (int i = 0; i < expectedTilesCount; ++i)
 {
 if (helpers::getTileMessage(*con->getWS(), con->getName()).empty())
 {
 return false;
 }
+}
 
 const auto now = std::chrono::steady_clock::now();
-
-const auto deltaRendering = 
std::chrono::duration_cast(now - 
startRendering).count();
-_renderingStats.push_back(deltaRendering);
-
-const auto deltaModify = 
std::chrono::duration_cast(now - 
startModify).count();
-_latencyStats.push_back(deltaModify);
-}
+const auto delta = 
std::chrono::duration_cast(now - start).count();
+_renderingStats.push_back(delta / expectedTilesCount);
 
 return true;
 }
@@ -238,19 +245,20 @@ private:
 {
 const auto start = std::chrono::steady_clock::now();
 
-auto expectedTilesCount = 3;
-con->send("tilecombine part=0 width=256 height=256 
tileposx=0,3840,7680 tileposy=0,0,0 tilewidth=3840 tileheight=3840");
+const auto expectedTilesCount = FIRST_PAGE_TILE_COUNT;
+con->send(FIRST_PAGE_TILES);
 for (int i = 0; i < expectedTilesCount; ++i)
 {
 if (helpers::getTileMessage(*con->getWS(), con->getName()).empty())
 {
 return false;
 }
-
-const auto delta = 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 - start).count();
-_cacheStats.push_back(delta);
 }
 
+const auto now = std::chrono::steady_clock::now();
+const auto delta = 
std::chrono::duration_cast(now - start).count();
+_cacheStats.push_back(delta / expectedTilesCount);
+
 return true;
 }
 
@@ -456,7 +464,7 @@ void Stress::handleOption(const std::string& optionName,
 else if (optionName == "bench")
 Stress::Benchmark = true;
 else if (optionName == "iter")
-Stress::Iterations = std::max(std::stoi(value), 10);
+Stress::Iterations = std::max(std::stoi(value), 1);
 else if (optionName == "nodelay")
 Stress::NoDelay = true;
 else if (optionName == "clientsperdoc")
@@ -522,6 +530,7 @@ int Stress::main(const std::vector& args)
 if (!latencyStats.empty() && !renderingStats.empty() && 
!cachedStats.empty())
 {
 std::cerr << "\nResults:\n";
+

[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-09-19 Thread Miklos Vajna
 loolwsd/LOOLStress.cpp |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit e2029921cbc8053ba82e32cbc90fa48d45db2b35
Author: Miklos Vajna 
Date:   Mon Sep 19 09:21:47 2016 +0200

LOOLStress: avoid multiplying at int precision, then converting to long

Change-Id: Ie79296522d09be0f337f218bede1a28e9bac3a7c

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index b4478b4..2929bee 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -53,7 +53,7 @@ public:
 ~Stress() {}
 
 static bool Benchmark;
-static int Iterations;
+static size_t Iterations;
 static bool NoDelay;
 unsigned _numClients;
 std::string _serverURI;
@@ -268,7 +268,7 @@ private:
 
 connection->load();
 
-for (auto i = 0; i < Stress::Iterations; ++i)
+for (size_t i = 0; i < Stress::Iterations; ++i)
 {
 renderTile(connection);
 
@@ -405,7 +405,7 @@ private:
 
 bool Stress::NoDelay = false;
 bool Stress::Benchmark = false;
-int Stress::Iterations = 100;
+size_t Stress::Iterations = 100;
 
 Stress::Stress() :
 _numClients(1),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-09-16 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit a0478719ffde1bbfd7994bd57665e40cb54982ce
Author: Ashod Nakashian 
Date:   Fri Sep 2 17:50:59 2016 -0400

loolwsd: benchmark iterations count as argument to the cli

Change-Id: I2598937ec01dbc4672f88f86d642b32b1b000d91
Reviewed-on: https://gerrit.libreoffice.org/28953
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index 237b4a0..fe9ca98 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -53,6 +53,7 @@ public:
 ~Stress() {}
 
 static bool Benchmark;
+static int Iterations;
 static bool NoDelay;
 unsigned _numClients;
 std::string _serverURI;
@@ -246,13 +247,14 @@ private:
 
 void benchmark()
 {
+std::cout << "Running " << Stress::Iterations << " iterations of 
Benchmark." << std::endl;
 static std::atomic SessionId;
 const auto sessionId = ++SessionId;
 auto connection = Connection::create(_app._serverURI, _uri, 
std::to_string(sessionId));
 
 connection->load();
 
-for (auto i = 0; i < 10; ++i)
+for (auto i = 0; i < Stress::Iterations; ++i)
 {
 renderTile(connection);
 
@@ -389,6 +391,7 @@ private:
 
 bool Stress::NoDelay = false;
 bool Stress::Benchmark = false;
+int Stress::Iterations = 100;
 
 Stress::Stress() :
 _numClients(1),
@@ -408,6 +411,9 @@ void Stress::defineOptions(OptionSet& optionSet)
 .required(false).repeatable(false));
 optionSet.addOption(Option("bench", "", "Performance benchmark. The 
argument is a document URL to load.")
 .required(false).repeatable(false));
+optionSet.addOption(Option("iter", "", "Number of iterations to use for 
Benchmarking.")
+.required(false).repeatable(false)
+.argument("iter"));
 optionSet.addOption(Option("nodelay", "", "Replay at full speed 
disregarding original timing.")
 .required(false).repeatable(false));
 optionSet.addOption(Option("clientsperdoc", "", "Number of simultaneous 
clients on each doc.")
@@ -435,6 +441,8 @@ void Stress::handleOption(const std::string& optionName,
 }
 else if (optionName == "bench")
 Stress::Benchmark = true;
+else if (optionName == "iter")
+Stress::Iterations = std::max(std::stoi(value), 10);
 else if (optionName == "nodelay")
 Stress::NoDelay = true;
 else if (optionName == "clientsperdoc")
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-09-16 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |   64 +++--
 1 file changed, 41 insertions(+), 23 deletions(-)

New commits:
commit 67c05ec319482bd8c4cde4583bba3a04dfead097
Author: Ashod Nakashian 
Date:   Sun Sep 11 14:22:24 2016 -0400

loolstress: improved benchmarking and stats

Change-Id: I8b9c2879dbc3ebc37df27eb5c4138bf48c4408c2
Reviewed-on: https://gerrit.libreoffice.org/28954
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index fe9ca98..b4478b4 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -213,19 +213,23 @@ private:
 
 const auto startRendering = std::chrono::steady_clock::now();
 
-con->send("tilecombine part=0 width=256 height=256 tileposx=0 
tileposy=0 tilewidth=3840 tileheight=3840");
-if (helpers::getTileMessage(*con->getWS(), con->getName()).empty())
+auto expectedTilesCount = 3;
+con->send("tilecombine part=0 width=256 height=256 
tileposx=0,3840,7680 tileposy=0,0,0 tilewidth=3840 tileheight=3840");
+for (int i = 0; i < expectedTilesCount; ++i)
 {
-return false;
-}
+if (helpers::getTileMessage(*con->getWS(), con->getName()).empty())
+{
+return false;
+}
 
 const auto now = std::chrono::steady_clock::now();
 
 const auto deltaRendering = 
std::chrono::duration_cast(now - 
startRendering).count();
 _renderingStats.push_back(deltaRendering);
 
-const auto deltaModify = 
std::chrono::duration_cast(now - 
startModify).count();
-_latencyStats.push_back(deltaModify);
+const auto deltaModify = 
std::chrono::duration_cast(now - 
startModify).count();
+_latencyStats.push_back(deltaModify);
+}
 
 return true;
 }
@@ -234,20 +238,30 @@ private:
 {
 const auto start = std::chrono::steady_clock::now();
 
-con->send("tilecombine part=0 width=256 height=256 tileposx=0 
tileposy=0 tilewidth=3840 tileheight=3840");
-if (helpers::getTileMessage(*con->getWS(), con->getName()).empty())
+auto expectedTilesCount = 3;
+con->send("tilecombine part=0 width=256 height=256 
tileposx=0,3840,7680 tileposy=0,0,0 tilewidth=3840 tileheight=3840");
+for (int i = 0; i < expectedTilesCount; ++i)
 {
-return false;
+if (helpers::getTileMessage(*con->getWS(), con->getName()).empty())
+{
+return false;
+}
+
+const auto delta = 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 - start).count();
+_cacheStats.push_back(delta);
 }
 
-const auto delta = 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 - start).count();
-_cacheStats.push_back(delta);
 return true;
 }
 
 void benchmark()
 {
 std::cout << "Running " << Stress::Iterations << " iterations of 
Benchmark." << std::endl;
+
+_cacheStats.reserve(Stress::Iterations * 4);
+_latencyStats.reserve(Stress::Iterations * 4);
+_renderingStats.reserve(Stress::Iterations * 4);
+
 static std::atomic SessionId;
 const auto sessionId = ++SessionId;
 auto connection = Connection::create(_app._serverURI, _uri, 
std::to_string(sessionId));
@@ -505,20 +519,24 @@ int Stress::main(const std::vector& args)
 cachedStats.insert(cachedStats.end(), cachedStat.begin(), 
cachedStat.end());
 }
 
-std::cerr << "\nResults:\n";
-std::cerr << "Latency best: " << latencyStats[0] << " microsecs, 95th 
percentile: " << percentile(latencyStats, 95) << " microsecs." << std::endl;
-std::cerr << "Tile best: " << renderingStats[0] << " microsecs, 
rendering 95th percentile: " << percentile(renderingStats, 95) << " microsecs." 
<< std::endl;
-std::cerr << "Cached best: " << cachedStats[0] << " microsecs, tile 
95th percentile: " << percentile(cachedStats, 95) << " microsecs." << std::endl;
+if (!latencyStats.empty() && !renderingStats.empty() && 
!cachedStats.empty())
+{
+std::cerr << "\nResults:\n";
+
+std::cerr << "Latency best: " << latencyStats[0] << " microsecs, 
95th percentile: " << percentile(latencyStats, 95) << " microsecs." << 
std::endl;
+std::cerr << "Tile best: " << renderingStats[0] << " microsecs, 
rendering 95th percentile: " << percentile(renderingStats, 95) << " microsecs." 
<< std::endl;
+std::cerr << "Cached best: " << cachedStats[0] << " microsecs, 
tile 95th percentile: " << percentile(cachedStats, 95) << " microsecs." << 
std::endl;
 
-const auto renderingTime = std::accumulate(renderingStats.begin(), 
renderingStats.end(), 0L);
-const double renderedPixels = 256 * 256 * 

[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-09-16 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |   38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

New commits:
commit fcb7da4c76c32fe5a7b6df9afe594680425389a4
Author: Ashod Nakashian 
Date:   Fri Sep 2 16:35:44 2016 -0400

loolstress: cout <-> cerr

Change-Id: I5bd530ccddab357054a9093bec54807a649dbe05
Reviewed-on: https://gerrit.libreoffice.org/28952
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index a296571..237b4a0 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -112,7 +112,7 @@ public:
 Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
"/lool/ws/" + documentURL);
 Poco::Net::HTTPResponse response;
 auto ws = helpers::connectLOKit(uri, request, response, sessionId + ' 
');
-std::cerr << "Connected.\n";
+std::cout << "Connected.\n";
 return std::shared_ptr(new Connection(documentURL, 
sessionId, ws));
 }
 
@@ -187,12 +187,12 @@ public:
 }
 catch (const Poco::Exception )
 {
-std::cerr << "Error: " << e.name() << ' '
+std::cout << "Error: " << e.name() << ' '
   << e.message() << std::endl;
 }
 catch (const std::exception )
 {
-std::cerr << "Error: " << e.what() << std::endl;
+std::cout << "Error: " << e.what() << std::endl;
 }
 }
 
@@ -283,7 +283,7 @@ private:
 {
 if (delay > 1e6)
 {
-std::cerr << "Sleeping for " << delay / 1000 << " ms.\n";
+std::cout << "Sleeping for " << delay / 1000 << " ms.\n";
 }
 
 std::this_thread::sleep_for(std::chrono::microseconds(delay));
@@ -304,7 +304,7 @@ private:
 // Add a new session.
 if (it->second.find(rec.SessionId) != it->second.end())
 {
-std::cerr << "ERROR: session [" << rec.SessionId 
<< "] already exists on doc [" << uri << "]\n";
+std::cout << "ERROR: session [" << rec.SessionId 
<< "] already exists on doc [" << uri << "]\n";
 }
 else
 {
@@ -313,7 +313,7 @@ private:
 }
 else
 {
-std::cerr << "New Document: " << uri << "\n";
+std::cout << "New Document: " << uri << "\n";
 _childToDoc.emplace(rec.Pid, uri);
 _sessions[uri].emplace(rec.SessionId, 
Connection::create(_app._serverURI, uri, rec.SessionId));
 }
@@ -324,19 +324,19 @@ private:
 auto it = _sessions.find(uri);
 if (it != _sessions.end())
 {
-std::cerr << "EndSession [" << rec.SessionId << "]: " 
<< uri << "\n";
+std::cout << "EndSession [" << rec.SessionId << "]: " 
<< uri << "\n";
 
 it->second.erase(rec.SessionId);
 if (it->second.empty())
 {
-std::cerr << "End Doc [" << uri << "].\n";
+std::cout << "End Doc [" << uri << "].\n";
 _sessions.erase(it);
 _childToDoc.erase(rec.Pid);
 }
 }
 else
 {
-std::cerr << "ERROR: Doc [" << uri << "] does not 
exist.\n";
+std::cout << "ERROR: Doc [" << uri << "] does not 
exist.\n";
 }
 }
 }
@@ -358,12 +358,12 @@ private:
 }
 else
 {
-std::cerr << "ERROR: Doc [" << uri << "] does not 
exist.\n";
+std::cout << "ERROR: Doc [" << uri << "] does not 
exist.\n";
 }
 }
 else
 {
-std::cerr << "ERROR: Unknown PID [" << rec.Pid << "] maps 
to no active document.\n";
+std::cout << "ERROR: Unknown PID [" << rec.Pid << "] maps 
to no active document.\n";
 }
 }
 
@@ -430,7 +430,7 @@ void Stress::handleOption(const std::string& optionName,
 helpFormatter.setCommand(commandName());
 helpFormatter.setUsage("OPTIONS");
 helpFormatter.setHeader("LibreOffice On-Line tool.");
-helpFormatter.format(std::cout);
+helpFormatter.format(std::cerr);
 std::exit(Application::EXIT_OK);
 }
 else if (optionName == "bench")
@@ -443,7 +443,7 @@ void 

[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-09-14 Thread Miklos Vajna
 loolwsd/LOOLStress.cpp |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

New commits:
commit a652a013aac06a848c9c7b82671b43d7be5cbbc1
Author: Miklos Vajna 
Date:   Wed Sep 14 09:20:35 2016 +0200

LOOLStress: unused using declaration

Change-Id: If20c38a4575074e7ca30069115002aadd1a1847f

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index 8290298..a296571 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -66,7 +66,6 @@ protected:
 
 using namespace LOOLProtocol;
 
-using Poco::Net::HTTPClientSession;
 using Poco::Net::HTTPRequest;
 using Poco::Net::HTTPResponse;
 using Poco::Runnable;
@@ -503,12 +502,12 @@ int Stress::main(const std::vector& args)
 std::cout << "Tile best: " << renderingStats[0] << " microsecs, 
rendering 95th percentile: " << percentile(renderingStats, 95) << " microsecs." 
<< std::endl;
 std::cout << "Cached best: " << cachedStats[0] << " microsecs, tile 
95th percentile: " << percentile(cachedStats, 95) << " microsecs." << std::endl;
 
-const auto renderingTime = std::accumulate(renderingStats.begin(), 
renderingStats.end(), 0);
+const auto renderingTime = std::accumulate(renderingStats.begin(), 
renderingStats.end(), 0L);
 const double renderedPixels = 256 * 256 * renderingStats.size();
 const auto pixelsPerSecRendered = renderedPixels / renderingTime;
 std::cout << "Rendering power: " << pixelsPerSecRendered << " 
MPixels/sec." << std::endl;
 
-const auto cacheTime = std::accumulate(cachedStats.begin(), 
cachedStats.end(), 0);
+const auto cacheTime = std::accumulate(cachedStats.begin(), 
cachedStats.end(), 0L);
 const double cachePixels = 256 * 256 * cachedStats.size();
 const auto pixelsPerSecCached = cachePixels / cacheTime;
 std::cout << "Cache power: " << pixelsPerSecCached << " MPixels/sec." 
<< std::endl;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-08-22 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |   60 +
 1 file changed, 56 insertions(+), 4 deletions(-)

New commits:
commit 8506c31a432262315927c9839ed580dcecb538b0
Author: Ashod Nakashian 
Date:   Sun Aug 21 20:18:37 2016 -0400

loolstress: latency and tile-rendering benchmark tests

Document modify round-trip benchmark and tile-rendering
round-trip benchmarks added to loolstress.

Change-Id: If3b6932f3a64008b1dbeb23da8a5e98ecedd66c8
Reviewed-on: https://gerrit.libreoffice.org/28309
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index 1c5780a..af26b17 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -82,7 +82,7 @@ class Connection
 {
 public:
 static
-std::unique_ptr create(const std::string& serverURI, const 
std::string& documentURL, const std::string& sessionId)
+std::shared_ptr create(const std::string& serverURI, const 
std::string& documentURL, const std::string& sessionId)
 {
 Poco::URI uri(serverURI);
 
@@ -94,9 +94,12 @@ public:
 Poco::Net::HTTPResponse response;
 auto ws = helpers::connectLOKit(uri, request, response, sessionId + ' 
');
 std::cerr << "Connected.\n";
-return std::unique_ptr(new Connection(documentURL, 
sessionId, ws));
+return std::shared_ptr(new Connection(documentURL, 
sessionId, ws));
 }
 
+const std::string& getName() const { return _name; }
+std::shared_ptr getWS() const { return _ws; };
+
 /// Send a command to the server.
 void send(const std::string& data) const
 {
@@ -146,6 +149,10 @@ public:
 {
 }
 
+std::vector getLatencyStats() const { return _latencyStats; }
+std::vector getRenderingStats() const { return _renderingStats; }
+std::vector getCacheStats() const { return _cacheStats; }
+
 void run() override
 {
 try
@@ -172,11 +179,52 @@ public:
 
 private:
 
+bool modifyDoc(const std::shared_ptr& con)
+{
+const auto start = std::chrono::steady_clock::now();
+
+con->send("key type=input char=97 key=0");
+if (con->recv("invalidatetiles:").empty())
+{
+return false;
+}
+
+const auto delta = 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 - start).count();
+std::cout << "Round-trip in: " << delta << std::endl;
+_latencyStats.push_back(delta);
+return true;
+}
+
+bool fetchTile(const std::shared_ptr& con)
+{
+const auto start = std::chrono::steady_clock::now();
+
+con->send("tilecombine part=0 width=256 height=256 tileposx=0 
tileposy=0 tilewidth=3840 tileheight=3840");
+if (helpers::getTileMessage(*con->getWS(), con->getName()).empty())
+{
+return false;
+}
+
+const auto delta = 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 - start).count();
+std::cout << "Rendered in: " << delta << std::endl;
+_renderingStats.push_back(delta);
+return true;
+}
+
 void benchmark()
 {
-auto connection = Connection::create(_app._serverURI, _uri, "0001");
+static std::atomic SessionId;
+const auto sessionId = ++SessionId;
+auto connection = Connection::create(_app._serverURI, _uri, 
std::to_string(sessionId));
 
 connection->load();
+
+for (auto i = 0; i < 100; ++i)
+{
+modifyDoc(connection);
+}
+
+fetchTile(connection);
 }
 
 void replay()
@@ -299,7 +347,11 @@ private:
 std::map _childToDoc;
 
 /// Doc URI to _sessions map. _sessions are maps of SessionID to 
Connection.
-std::map> 
_sessions;
+std::map> 
_sessions;
+
+std::vector _latencyStats;
+std::vector _renderingStats;
+std::vector _cacheStats;
 };
 
 bool Stress::NoDelay = false;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp loolwsd/test

2016-08-22 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp   |   99 ---
 loolwsd/test/helpers.hpp |8 +--
 2 files changed, 89 insertions(+), 18 deletions(-)

New commits:
commit 5656f844015d9c6e7d70e3bd55fcd313817afb94
Author: Ashod Nakashian 
Date:   Sun Aug 21 23:34:02 2016 -0400

loolstress: benchmark statistics are calculated and reported

Statistics include:
Total latency from input to tile.
Tile rendering time.
Tile-cache response time.

The lowest latency for each is reported and the
95th percentile as well.

The rendering and cache-serving power is
calculated as Mega-Pixels per second.

Change-Id: Ib1baede818444c92f553eaf3e6b17dc617c51b0f
Reviewed-on: https://gerrit.libreoffice.org/28310
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index af26b17..8290298 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -77,6 +77,26 @@ using Poco::Util::HelpFormatter;
 using Poco::Util::Option;
 using Poco::Util::OptionSet;
 
+long percentile(std::vector& v, const double percentile)
+{
+std::sort(v.begin(), v.end());
+
+const auto N = v.size();
+const double n = (N - 1) * percentile / 100.0 + 1;
+if (n <= 1)
+{
+return v[0];
+}
+else if (n >= N)
+{
+return v[N - 1];
+}
+
+const auto k = static_cast(n);
+const double d = n - k;
+return v[k - 1] + d * (v[k] - v[k - 1]);
+}
+
 /// Connection class with WSD.
 class Connection
 {
@@ -181,21 +201,36 @@ private:
 
 bool modifyDoc(const std::shared_ptr& con)
 {
-const auto start = std::chrono::steady_clock::now();
-
 con->send("key type=input char=97 key=0");
-if (con->recv("invalidatetiles:").empty())
+return !con->recv("invalidatetiles:").empty();
+}
+
+bool renderTile(const std::shared_ptr& con)
+{
+const auto startModify = std::chrono::steady_clock::now();
+
+modifyDoc(con);
+
+const auto startRendering = std::chrono::steady_clock::now();
+
+con->send("tilecombine part=0 width=256 height=256 tileposx=0 
tileposy=0 tilewidth=3840 tileheight=3840");
+if (helpers::getTileMessage(*con->getWS(), con->getName()).empty())
 {
 return false;
 }
 
-const auto delta = 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 - start).count();
-std::cout << "Round-trip in: " << delta << std::endl;
-_latencyStats.push_back(delta);
+const auto now = std::chrono::steady_clock::now();
+
+const auto deltaRendering = 
std::chrono::duration_cast(now - 
startRendering).count();
+_renderingStats.push_back(deltaRendering);
+
+const auto deltaModify = 
std::chrono::duration_cast(now - 
startModify).count();
+_latencyStats.push_back(deltaModify);
+
 return true;
 }
 
-bool fetchTile(const std::shared_ptr& con)
+bool fetchCachedTile(const std::shared_ptr& con)
 {
 const auto start = std::chrono::steady_clock::now();
 
@@ -206,8 +241,7 @@ private:
 }
 
 const auto delta = 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 - start).count();
-std::cout << "Rendered in: " << delta << std::endl;
-_renderingStats.push_back(delta);
+_cacheStats.push_back(delta);
 return true;
 }
 
@@ -219,12 +253,12 @@ private:
 
 connection->load();
 
-for (auto i = 0; i < 100; ++i)
+for (auto i = 0; i < 10; ++i)
 {
-modifyDoc(connection);
-}
+renderTile(connection);
 
-fetchTile(connection);
+fetchCachedTile(connection);
+}
 }
 
 void replay()
@@ -427,14 +461,17 @@ int Stress::main(const std::vector& args)
 return Application::EXIT_NOINPUT;
 }
 
+std::vector workers;
+
 unsigned index = 0;
 for (unsigned i = 0; i < args.size(); ++i)
 {
 std::cout << "Arg: " << args[i] << std::endl;
 for (unsigned j = 0; j < _numClients; ++j, ++index)
 {
+workers.emplace_back(new Worker(*this, args[i]));
 clients[index].reset(new Thread());
-clients[index]->start(*(new Worker(*this, args[i])));
+clients[index]->start(*workers[workers.size() - 1]);
 }
 }
 
@@ -443,6 +480,40 @@ int Stress::main(const std::vector& args)
 client->join();
 }
 
+if (Stress::Benchmark)
+{
+std::vector latencyStats;
+std::vector renderingStats;
+std::vector cachedStats;
+
+for (const auto& worker : workers)
+{
+const auto latencyStat = worker->getLatencyStats();
+latencyStats.insert(latencyStats.end(), latencyStat.begin(), 
latencyStat.end());
+
+const 

[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-08-21 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |   60 -
 1 file changed, 49 insertions(+), 11 deletions(-)

New commits:
commit baef50055f465abfca0b479d1427870371fe1fd4
Author: Ashod Nakashian 
Date:   Sun Aug 21 14:44:24 2016 -0400

loolstress: support for benchmarking

Change-Id: I100ee5ced96f876047598e42bd83257f8dd9581a
Reviewed-on: https://gerrit.libreoffice.org/28307
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index 2514b14..1c5780a 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -52,8 +52,9 @@ public:
 Stress();
 ~Stress() {}
 
+static bool Benchmark;
 static bool NoDelay;
-unsigned_numClients;
+unsigned _numClients;
 std::string _serverURI;
 
 protected:
@@ -91,20 +92,35 @@ public:
 std::cout << "NewSession [" << sessionId << "]: " << uri.toString() << 
"... ";
 Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
"/lool/ws/" + documentURL);
 Poco::Net::HTTPResponse response;
-auto ws = helpers::connectLOKit(uri, request, response, "loolStress ");
+auto ws = helpers::connectLOKit(uri, request, response, sessionId + ' 
');
 std::cerr << "Connected.\n";
 return std::unique_ptr(new Connection(documentURL, 
sessionId, ws));
 }
 
+/// Send a command to the server.
 void send(const std::string& data) const
 {
-helpers::sendTextFrame(_ws, data, _sessionId + ' ');
+helpers::sendTextFrame(_ws, data, _name);
+}
+
+/// Poll socket until expected prefix is fetched, or timeout.
+std::vector recv(const std::string& prefix)
+{
+return helpers::getResponseMessage(_ws, prefix, _name);
+}
+
+/// Request loading the document and wait for completion.
+bool load()
+{
+send("load url=" + _documentURL);
+return helpers::isDocumentLoaded(_ws, _name);
 }
 
 private:
 Connection(const std::string& documentURL, const std::string& sessionId, 
std::shared_ptr& ws) :
 _documentURL(documentURL),
 _sessionId(sessionId),
+_name(sessionId + ' '),
 _ws(ws)
 {
 }
@@ -112,6 +128,7 @@ private:
 private:
 const std::string _documentURL;
 const std::string _sessionId;
+const std::string _name;
 std::shared_ptr _ws;
 static std::mutex Mutex;
 };
@@ -123,9 +140,9 @@ class Worker: public Runnable
 {
 public:
 
-Worker(Stress& app, const std::string& traceFilePath) :
+Worker(Stress& app, const std::string& uri) :
 _app(app),
-_traceFile(traceFilePath)
+_uri(uri)
 {
 }
 
@@ -133,7 +150,14 @@ public:
 {
 try
 {
-doRun();
+if (Stress::Benchmark)
+{
+benchmark();
+}
+else
+{
+replay();
+}
 }
 catch (const Poco::Exception )
 {
@@ -148,14 +172,23 @@ public:
 
 private:
 
-void doRun()
+void benchmark()
+{
+auto connection = Connection::create(_app._serverURI, _uri, "0001");
+
+connection->load();
+}
+
+void replay()
 {
-auto epochFile(_traceFile.getEpoch());
+TraceFileReader traceFile(_uri);
+
+auto epochFile(traceFile.getEpoch());
 auto epochCurrent(std::chrono::steady_clock::now());
 
 for (;;)
 {
-const auto rec = _traceFile.getNextRecord();
+const auto rec = traceFile.getNextRecord();
 if (rec.Dir == TraceFileRecord::Direction::Invalid)
 {
 // End of trace file.
@@ -260,7 +293,7 @@ private:
 
 private:
 Stress& _app;
-TraceFileReader _traceFile;
+const std::string _uri;
 
 /// LOK child process PID to Doc URI map.
 std::map _childToDoc;
@@ -270,6 +303,7 @@ private:
 };
 
 bool Stress::NoDelay = false;
+bool Stress::Benchmark = false;
 
 Stress::Stress() :
 _numClients(1),
@@ -287,6 +321,8 @@ void Stress::defineOptions(OptionSet& optionSet)
 
 optionSet.addOption(Option("help", "", "Display help information on 
command line arguments.")
 .required(false).repeatable(false));
+optionSet.addOption(Option("bench", "", "Performance benchmark. The 
argument is a document URL to load.")
+.required(false).repeatable(false));
 optionSet.addOption(Option("nodelay", "", "Replay at full speed 
disregarding original timing.")
 .required(false).repeatable(false));
 optionSet.addOption(Option("clientsperdoc", "", "Number of simultaneous 
clients on each doc.")
@@ -312,6 +348,8 @@ void Stress::handleOption(const std::string& optionName,
 helpFormatter.format(std::cout);
 

[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-08-21 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |5 +
 1 file changed, 5 insertions(+)

New commits:
commit c98af7c5a0436edf9c682e7debad0776d22031b7
Author: Ashod Nakashian 
Date:   Sun Aug 21 08:21:59 2016 -0400

loolwsd: Poco HTTPRequest and co are not thread-safe

Change-Id: I5b7a290651a51f117da1dd972f4c24bdebd2b3b2
Reviewed-on: https://gerrit.libreoffice.org/28300
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index 9d331d1..380bb85 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -85,6 +85,8 @@ public:
 {
 Poco::URI uri(serverURI);
 
+std::unique_lock lock(Mutex);
+
 // Load a document and get its status.
 std::cerr << "NewSession [" << sessionId << "]: " << uri.toString() << 
"... ";
 Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
"/lool/ws/" + documentURL);
@@ -111,8 +113,11 @@ private:
 const std::string _documentURL;
 const std::string _sessionId;
 std::shared_ptr _ws;
+static std::mutex Mutex;
 };
 
+std::mutex Connection::Mutex;
+
 /// Main thread class to replay a trace file.
 class Worker: public Runnable
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-08-21 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |   30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

New commits:
commit bea85403eab7594a89a5c3b608a833ae5fbfc95a
Author: Ashod Nakashian 
Date:   Thu Aug 18 07:52:40 2016 -0400

loolstress: non-static member naming convention fix

Change-Id: I33eebfcde89e39f39491edad32d3eab50761b073
Reviewed-on: https://gerrit.libreoffice.org/28290
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index b6b6f8a..9d331d1 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -174,8 +174,8 @@ private:
 if (rec.Payload.find(NewSession) == 0)
 {
 const auto& uri = rec.Payload.substr(NewSession.size());
-auto it = Sessions.find(uri);
-if (it != Sessions.end())
+auto it = _sessions.find(uri);
+if (it != _sessions.end())
 {
 // Add a new session.
 if (it->second.find(rec.SessionId) != it->second.end())
@@ -190,15 +190,15 @@ private:
 else
 {
 std::cerr << "New Document: " << uri << "\n";
-ChildToDoc.emplace(rec.Pid, uri);
-Sessions[uri].emplace(rec.SessionId, 
Connection::create(_app._serverURI, uri, rec.SessionId));
+_childToDoc.emplace(rec.Pid, uri);
+_sessions[uri].emplace(rec.SessionId, 
Connection::create(_app._serverURI, uri, rec.SessionId));
 }
 }
 else if (rec.Payload.find(EndSession) == 0)
 {
 const auto& uri = rec.Payload.substr(EndSession.size());
-auto it = Sessions.find(uri);
-if (it != Sessions.end())
+auto it = _sessions.find(uri);
+if (it != _sessions.end())
 {
 std::cerr << "EndSession [" << rec.SessionId << "]: " 
<< uri << "\n";
 
@@ -206,8 +206,8 @@ private:
 if (it->second.empty())
 {
 std::cerr << "End Doc [" << uri << "].\n";
-Sessions.erase(it);
-ChildToDoc.erase(rec.Pid);
+_sessions.erase(it);
+_childToDoc.erase(rec.Pid);
 }
 }
 else
@@ -218,12 +218,12 @@ private:
 }
 else if (rec.Dir == TraceFileRecord::Direction::Incoming)
 {
-auto docIt = ChildToDoc.find(rec.Pid);
-if (docIt != ChildToDoc.end())
+auto docIt = _childToDoc.find(rec.Pid);
+if (docIt != _childToDoc.end())
 {
 const auto& uri = docIt->second;
-auto it = Sessions.find(uri);
-if (it != Sessions.end())
+auto it = _sessions.find(uri);
+if (it != _sessions.end())
 {
 const auto sessionIt = it->second.find(rec.SessionId);
 if (sessionIt != it->second.end())
@@ -252,10 +252,10 @@ private:
 TraceFileReader _traceFile;
 
 /// LOK child process PID to Doc URI map.
-std::map ChildToDoc;
+std::map _childToDoc;
 
-/// Doc URI to Sessions map. Sessions are maps of SessionID to Connection.
-std::map> 
Sessions;
+/// Doc URI to _sessions map. _sessions are maps of SessionID to 
Connection.
+std::map> 
_sessions;
 };
 
 bool Stress::NoDelay = false;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-08-21 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 60e7c0b50ed986b2e1d6c6d93071ce3eff0c7166
Author: Ashod Nakashian 
Date:   Wed Aug 17 19:52:13 2016 -0400

loolstress: usage

Change-Id: I04df4341dbe669b35c0c5cad6e17cd08a8faa05c
Reviewed-on: https://gerrit.libreoffice.org/28287
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index 5d5e374..b6b6f8a 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -318,7 +318,13 @@ int Stress::main(const std::vector& args)
 {
 std::vector clients(_numClients * args.size());
 
-std::cout << "Args: " << args.size() << std::endl;
+if (args.size() == 0)
+{
+std::cerr << "Usage: loolstress  " << std::endl;
+std::cerr << "   Trace files may be plain text or gzipped (with 
.gz extension)." << std::endl;
+std::cerr << "   --help for full arguments list." << std::endl;
+return Application::EXIT_NOINPUT;
+}
 
 unsigned index = 0;
 for (unsigned i = 0; i < args.size(); ++i)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-08-07 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |   14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

New commits:
commit 7ae28d5642cb99595b804561ebcd034a96f12706
Author: Ashod Nakashian 
Date:   Thu Aug 4 20:17:13 2016 -0400

loolstress: new option to replay without timing delays

Change-Id: Ic1f6c911f504128b7d1aa5e3ee2354e382b825c5
Reviewed-on: https://gerrit.libreoffice.org/27971
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index f042901..9b7981c 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -53,6 +53,7 @@ public:
 Stress();
 ~Stress() {}
 
+static bool NoDelay;
 unsigned_numClients;
 std::string _serverURI;
 
@@ -152,9 +153,14 @@ private:
 
 const auto deltaCurrent = 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 - epochCurrent).count();
 const auto deltaFile = rec.TimestampNs - epochFile;
-const auto delay = deltaFile - deltaCurrent;
+const auto delay = (Stress::NoDelay ? 0 : deltaFile - 
deltaCurrent);
 if (delay > 0)
 {
+if (delay > 1e6)
+{
+std::cerr << "Sleeping for " << delay / 1000 << " ms.\n";
+}
+
 std::this_thread::sleep_for(std::chrono::microseconds(delay));
 }
 
@@ -251,6 +257,8 @@ private:
 std::map> 
Sessions;
 };
 
+bool Stress::NoDelay = false;
+
 Stress::Stress() :
 _numClients(1),
 #if ENABLE_SSL
@@ -267,6 +275,8 @@ void Stress::defineOptions(OptionSet& optionSet)
 
 optionSet.addOption(Option("help", "", "Display help information on 
command line arguments.")
 .required(false).repeatable(false));
+optionSet.addOption(Option("nodelay", "", "Replay at full speed 
disregarding original timing.")
+.required(false).repeatable(false));
 optionSet.addOption(Option("clientsperdoc", "", "Number of simultaneous 
clients on each doc.")
 .required(false).repeatable(false)
 .argument("concurrency"));
@@ -290,6 +300,8 @@ void Stress::handleOption(const std::string& optionName,
 helpFormatter.format(std::cout);
 std::exit(Application::EXIT_OK);
 }
+else if (optionName == "nodelay")
+Stress::NoDelay = true;
 else if (optionName == "clientsperdoc")
 _numClients = std::max(std::stoi(value), 1);
 else if (optionName == "server")
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp loolwsd/TraceFile.hpp

2016-08-07 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |  159 ++---
 loolwsd/TraceFile.hpp  |   14 ++--
 2 files changed, 94 insertions(+), 79 deletions(-)

New commits:
commit f9ec1bade3325fc4c3505b60ef63665d32e38739
Author: Ashod Nakashian 
Date:   Thu Aug 4 12:17:22 2016 -0400

loolstress: time-accurate replay

Change-Id: I1aff521f042c61916ef6ddfc50c2fe06c41b29ee
Reviewed-on: https://gerrit.libreoffice.org/27968
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index f60aa55..f042901 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -124,108 +124,119 @@ public:
 
 void run() override
 {
-const auto epochStart(std::chrono::steady_clock::now());
 try
 {
-for (;;)
+doRun();
+}
+catch (const Poco::Exception )
+{
+std::cerr << "Error: " << e.name() << ' '
+  << e.message() << std::endl;
+}
+}
+
+private:
+
+void doRun()
+{
+auto epochFile(_traceFile.getEpoch());
+auto epochCurrent(std::chrono::steady_clock::now());
+for (;;)
+{
+const auto rec = _traceFile.getNextRecord();
+if (rec.Dir == TraceFileRecord::Direction::Invalid)
 {
-const auto rec = _traceFile.getNextRecord();
-if (rec.Dir == TraceFileRecord::Direction::Invalid)
-{
-// End of trace file.
-break;
-}
+// End of trace file.
+break;
+}
 
-const auto delta = (epochStart - 
std::chrono::steady_clock::now());
-const auto delay = rec.TimestampNs - 
std::chrono::duration_cast(delta).count();
-if (delay > 0)
-{
-
std::this_thread::sleep_for(std::chrono::microseconds(delay));
-}
+const auto deltaCurrent = 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 - epochCurrent).count();
+const auto deltaFile = rec.TimestampNs - epochFile;
+const auto delay = deltaFile - deltaCurrent;
+if (delay > 0)
+{
+std::this_thread::sleep_for(std::chrono::microseconds(delay));
+}
 
-if (rec.Dir == TraceFileRecord::Direction::Event)
-{
-// Meta info about about an event.
-static const std::string NewSession("NewSession: ");
-static const std::string EndSession("EndSession: ");
+if (rec.Dir == TraceFileRecord::Direction::Event)
+{
+// Meta info about about an event.
+static const std::string NewSession("NewSession: ");
+static const std::string EndSession("EndSession: ");
 
-if (rec.Payload.find(NewSession) == 0)
+if (rec.Payload.find(NewSession) == 0)
+{
+const auto& uri = rec.Payload.substr(NewSession.size());
+auto it = Sessions.find(uri);
+if (it != Sessions.end())
 {
-const auto& uri = 
rec.Payload.substr(NewSession.size());
-auto it = Sessions.find(uri);
-if (it != Sessions.end())
+// Add a new session.
+if (it->second.find(rec.SessionId) != it->second.end())
 {
-// Add a new session.
-if (it->second.find(rec.SessionId) != 
it->second.end())
-{
-std::cerr << "ERROR: session [" << 
rec.SessionId << "] already exists on doc [" << uri << "]\n";
-}
-else
-{
-it->second.emplace(rec.SessionId, 
Connection::create(_app._serverURI, uri, rec.SessionId));
-}
+std::cerr << "ERROR: session [" << rec.SessionId 
<< "] already exists on doc [" << uri << "]\n";
 }
 else
 {
-std::cerr << "New Document: " << uri << "\n";
-ChildToDoc.emplace(rec.Pid, uri);
-Sessions[uri].emplace(rec.SessionId, 
Connection::create(_app._serverURI, uri, rec.SessionId));
+it->second.emplace(rec.SessionId, 
Connection::create(_app._serverURI, uri, rec.SessionId));
 }
 }
-else if (rec.Payload.find(EndSession) == 0)
+ 

[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp loolwsd/LOOLWSD.cpp loolwsd/TraceFile.hpp

2016-08-07 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |  135 +++--
 loolwsd/LOOLWSD.cpp|5 -
 loolwsd/TraceFile.hpp  |   52 ++
 3 files changed, 152 insertions(+), 40 deletions(-)

New commits:
commit 7af51f51c4f4d89c837c96bd3c59e66288025a77
Author: Ashod Nakashian 
Date:   Thu Aug 4 10:31:11 2016 -0400

loolstress: new Connection manager and event handler

Change-Id: Ifc921f7fcf298457a848da444c2d3830b9755603
Reviewed-on: https://gerrit.libreoffice.org/27967
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index 6a7c38d..f60aa55 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -76,37 +76,63 @@ using Poco::Util::HelpFormatter;
 using Poco::Util::Option;
 using Poco::Util::OptionSet;
 
-class Worker: public Runnable
+class Connection
 {
 public:
+static
+std::unique_ptr create(const std::string& serverURI, const 
std::string& documentURL, const std::string& sessionId)
+{
+Poco::URI uri(serverURI);
 
-Worker(Stress& app, const std::string& traceFilePath) :
-_app(app), _traceFile(traceFilePath)
+// Load a document and get its status.
+std::cerr << "NewSession [" << sessionId << "]: " << uri.toString() << 
"... ";
+Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
"/lool/ws/" + documentURL);
+Poco::Net::HTTPResponse response;
+auto ws = helpers::connectLOKit(uri, request, response, "loolStress ");
+std::cerr << "Connected.\n";
+return std::unique_ptr(new Connection(documentURL, 
sessionId, ws));
+}
+
+void send(const std::string& data) const
 {
+helpers::sendTextFrame(_ws, data, "loolstress ");
 }
 
-void run() override
+private:
+Connection(const std::string& documentURL, const std::string& sessionId, 
std::shared_ptr& ws) :
+_documentURL(documentURL),
+_sessionId(sessionId),
+_ws(ws)
 {
-std::cerr << "Connecting to server: " << _app._serverURI << "\n";
+}
 
-Poco::URI uri(_app._serverURI);
+private:
+const std::string _documentURL;
+const std::string _sessionId;
+std::shared_ptr _ws;
+};
 
-const auto documentURL = _traceFile.getDocURI();
-std::cerr << "Loading: " << documentURL << "\n";
+class Worker: public Runnable
+{
+public:
 
-// Load a document and get its status.
-Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
documentURL);
-Poco::Net::HTTPResponse response;
-auto socket = helpers::connectLOKit(uri, request, response, 
"loolStress ");
+Worker(Stress& app, const std::string& traceFilePath) :
+_app(app),
+_traceFile(traceFilePath)
+{
+}
 
+void run() override
+{
 const auto epochStart(std::chrono::steady_clock::now());
 try
 {
 for (;;)
 {
-const auto rec = 
_traceFile.getNextRecord(TraceFileRecord::Direction::Incoming);
+const auto rec = _traceFile.getNextRecord();
 if (rec.Dir == TraceFileRecord::Direction::Invalid)
 {
+// End of trace file.
 break;
 }
 
@@ -117,7 +143,82 @@ public:
 
std::this_thread::sleep_for(std::chrono::microseconds(delay));
 }
 
-helpers::sendTextFrame(socket, rec.Payload);
+if (rec.Dir == TraceFileRecord::Direction::Event)
+{
+// Meta info about about an event.
+static const std::string NewSession("NewSession: ");
+static const std::string EndSession("EndSession: ");
+
+if (rec.Payload.find(NewSession) == 0)
+{
+const auto& uri = 
rec.Payload.substr(NewSession.size());
+auto it = Sessions.find(uri);
+if (it != Sessions.end())
+{
+// Add a new session.
+if (it->second.find(rec.SessionId) != 
it->second.end())
+{
+std::cerr << "ERROR: session [" << 
rec.SessionId << "] already exists on doc [" << uri << "]\n";
+}
+else
+{
+it->second.emplace(rec.SessionId, 
Connection::create(_app._serverURI, uri, rec.SessionId));
+}
+}
+else
+{
+std::cerr << "New Document: " << uri << "\n";
+ChildToDoc.emplace(rec.Pid, uri);
+

[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp

2016-08-07 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |   24 
 1 file changed, 20 insertions(+), 4 deletions(-)

New commits:
commit a750edd70dda63a2dd5ca3c72641b207d4f45c99
Author: Ashod Nakashian 
Date:   Mon Aug 1 22:21:06 2016 -0400

loolstress: replay trace file

Change-Id: I076ec4ff398cf22ca6916ad11afc9ecb75421ac1
Reviewed-on: https://gerrit.libreoffice.org/27963
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index c83d641..6a7c38d 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -10,11 +10,13 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -87,9 +89,6 @@ public:
 {
 std::cerr << "Connecting to server: " << _app._serverURI << "\n";
 
-const auto rec = 
_traceFile.getNextRecord(TraceFileRecord::Direction::Incoming);
-std::cout << rec.Payload << "\n";
-
 Poco::URI uri(_app._serverURI);
 
 const auto documentURL = _traceFile.getDocURI();
@@ -100,9 +99,26 @@ public:
 Poco::Net::HTTPResponse response;
 auto socket = helpers::connectLOKit(uri, request, response, 
"loolStress ");
 
+const auto epochStart(std::chrono::steady_clock::now());
 try
 {
-
+for (;;)
+{
+const auto rec = 
_traceFile.getNextRecord(TraceFileRecord::Direction::Incoming);
+if (rec.Dir == TraceFileRecord::Direction::Invalid)
+{
+break;
+}
+
+const auto delta = (epochStart - 
std::chrono::steady_clock::now());
+const auto delay = rec.TimestampNs - 
std::chrono::duration_cast(delta).count();
+if (delay > 0)
+{
+
std::this_thread::sleep_for(std::chrono::microseconds(delay));
+}
+
+helpers::sendTextFrame(socket, rec.Payload);
+}
 }
 catch (const Poco::Exception )
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp loolwsd/Makefile.am loolwsd/TraceFile.hpp

2016-08-07 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |   19 ++-
 loolwsd/Makefile.am|3 ++-
 loolwsd/TraceFile.hpp  |   22 ++
 3 files changed, 34 insertions(+), 10 deletions(-)

New commits:
commit 831a917977b040e157d544ace8835483f77c402c
Author: Ashod Nakashian 
Date:   Mon Aug 1 21:53:09 2016 -0400

loolstress: Parse trace file header and document URI

Change-Id: I659f9ec3d0cb9f1333d930d0b21c5b3afd115d32
Reviewed-on: https://gerrit.libreoffice.org/27962
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index ef06135..c83d641 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -85,19 +85,20 @@ public:
 
 void run() override
 {
-_traceFile.readFile();
-
 std::cerr << "Connecting to server: " << _app._serverURI << "\n";
 
+const auto rec = 
_traceFile.getNextRecord(TraceFileRecord::Direction::Incoming);
+std::cout << rec.Payload << "\n";
+
 Poco::URI uri(_app._serverURI);
 
-const auto documentURL = "lool/ws/file://" + 
Poco::Path(_traceFilePath).makeAbsolute().toString();
+const auto documentURL = _traceFile.getDocURI();
+std::cerr << "Loading: " << documentURL << "\n";
 
-std::unique_ptr session;
-if (_app._serverURI.compare(0, 5, "https"))
-session.reset(new Poco::Net::HTTPSClientSession(uri.getHost(), 
uri.getPort()));
-else
-session.reset(new Poco::Net::HTTPClientSession(uri.getHost(), 
uri.getPort()));
+// Load a document and get its status.
+Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, 
documentURL);
+Poco::Net::HTTPResponse response;
+auto socket = helpers::connectLOKit(uri, request, response, 
"loolStress ");
 
 try
 {
@@ -117,7 +118,7 @@ private:
 };
 
 Stress::Stress() :
-_numClients(4),
+_numClients(1),
 #if ENABLE_SSL
 _serverURI("https://127.0.0.1:; + 
std::to_string(DEFAULT_CLIENT_PORT_NUMBER))
 #else
diff --git a/loolwsd/Makefile.am b/loolwsd/Makefile.am
index d3cd9ef..4f36078 100644
--- a/loolwsd/Makefile.am
+++ b/loolwsd/Makefile.am
@@ -78,7 +78,8 @@ loolmap_SOURCES = loolmap.c
 
 looltool_SOURCES = LOOLTool.cpp
 
-loolstress_SOURCES = LOOLStress.cpp
+loolstress_SOURCES = LOOLStress.cpp \
+ LOOLProtocol.cpp
 
 noinst_HEADERS = Admin.hpp \
  AdminModel.hpp \
diff --git a/loolwsd/TraceFile.hpp b/loolwsd/TraceFile.hpp
index 41f316d..bb39c44 100644
--- a/loolwsd/TraceFile.hpp
+++ b/loolwsd/TraceFile.hpp
@@ -88,6 +88,8 @@ public:
 readFile();
 }
 
+const std::string& getDocURI() const { return _docURI; }
+
 TraceFileRecord getNextRecord(const TraceFileRecord::Direction dir)
 {
 if (dir == TraceFileRecord::Direction::Incoming)
@@ -134,6 +136,25 @@ private:
 
 _indexIn = advance(-1, TraceFileRecord::Direction::Incoming);
 _indexOut = advance(-1, TraceFileRecord::Direction::Outgoing);
+
+if (_records.size() > 1)
+{
+if (_records[0].Payload.find("loolclient") == 0 &&
+_records[1].Payload.find("load url=") == 0)
+{
+_docURI = _records[1].Payload.substr(9);
+return;
+}
+else if (_records[0].Payload.find("load url=") == 0)
+{
+_docURI = _records[0].Payload.substr(9);
+return;
+}
+}
+
+fprintf(stderr, "Invalid trace file with %ld records. First record: 
%s\n", _records.size(),
+_records.empty() ? "" : _records[0].Payload.c_str());
+throw std::runtime_error("Invalid trace file.");
 }
 
 std::vector split(const std::string& s, const char delim) 
const
@@ -169,6 +190,7 @@ private:
 const Poco::Int64 _epochStart;
 std::ifstream _stream;
 std::vector _records;
+std::string _docURI;
 unsigned _indexIn;
 unsigned _indexOut;
 };
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp loolwsd/TraceFile.hpp

2016-08-07 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |4 ++-
 loolwsd/TraceFile.hpp  |   55 +++--
 2 files changed, 56 insertions(+), 3 deletions(-)

New commits:
commit 4d7c2e4002b51d4a1347a5178103612df2985ddc
Author: Ashod Nakashian 
Date:   Sun Jul 31 18:06:01 2016 -0400

loolstress: parse trace file

Change-Id: I04964744a74d3a025e310d7ec52f5d1f5b6d100d
Reviewed-on: https://gerrit.libreoffice.org/27960
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index 6bda492..ef06135 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -79,12 +79,14 @@ class Worker: public Runnable
 public:
 
 Worker(Stress& app, const std::string& traceFilePath) :
-_app(app), _traceFilePath(traceFilePath)
+_app(app), _traceFile(traceFilePath)
 {
 }
 
 void run() override
 {
+_traceFile.readFile();
+
 std::cerr << "Connecting to server: " << _app._serverURI << "\n";
 
 Poco::URI uri(_app._serverURI);
diff --git a/loolwsd/TraceFile.hpp b/loolwsd/TraceFile.hpp
index 73713e6..cf51981 100644
--- a/loolwsd/TraceFile.hpp
+++ b/loolwsd/TraceFile.hpp
@@ -9,7 +9,9 @@
 
 #include 
 #include 
+#include 
 #include 
+#include 
 
 /// Dumps commands and notification trace.
 class TraceFileWriter
@@ -54,18 +56,67 @@ private:
 std::mutex _mutex;
 };
 
+class TraceFileRecord
+{
+public:
+enum class Direction
+{
+Incoming,
+Outgoing
+};
+
+Direction Dir;
+unsigned TimestampNs;
+std::string Payload;
+};
+
 class TraceFileReader
 {
 public:
 TraceFileReader(const std::string& path) :
 _epochStart(Poco::Timestamp().epochMicroseconds()),
-_stream(path, std::ios::in)
+_stream(path)
 {
 }
 
+void readFile()
+{
+std::string line;
+while (std::getline(_stream, line) && !line.empty())
+{
+const auto v = split(line, line[0]);
+if (v.size() == 2)
+{
+TraceFileRecord rec;
+rec.Dir = (line[0] == '>' ? 
TraceFileRecord::Direction::Incoming : TraceFileRecord::Direction::Outgoing);
+rec.TimestampNs = std::atoi(v[0].c_str());
+rec.Payload = v[1];
+_records.push_back(rec);
+}
+}
+}
+
+private:
+std::vector split(const std::string& s, const char delim)
+{
+std::stringstream ss(s);
+std::string item;
+std::vector v;
+while (std::getline(ss, item, delim))
+{
+if (!item.empty())
+{
+v.push_back(item);
+}
+}
+
+return v;
+}
+
 private:
 const Poco::Int64 _epochStart;
-std::fstream _stream;
+std::ifstream _stream;
+std::vector _records;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLStress.cpp loolwsd/TraceFile.hpp

2016-08-07 Thread Ashod Nakashian
 loolwsd/LOOLStress.cpp |   14 +-
 loolwsd/TraceFile.hpp  |   17 -
 2 files changed, 21 insertions(+), 10 deletions(-)

New commits:
commit b394ad89d87ef207f6b26d96134b345a8cf07112
Author: Ashod Nakashian 
Date:   Sun Jul 31 14:17:52 2016 -0400

loolstress: TraceFileReader class added

Change-Id: I81d508bb794ca56f647d0eb5b9dd27585100fe07
Reviewed-on: https://gerrit.libreoffice.org/27959
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLStress.cpp b/loolwsd/LOOLStress.cpp
index 6232128..6bda492 100644
--- a/loolwsd/LOOLStress.cpp
+++ b/loolwsd/LOOLStress.cpp
@@ -16,14 +16,9 @@
 #include 
 #include 
 
-#include 
 #include 
-#include 
-#include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -39,14 +34,15 @@
 #include 
 #include 
 
+#include 
+#include 
+
 #include "Common.hpp"
 #include "LOOLProtocol.hpp"
+#include "TraceFile.hpp"
 #include "Util.hpp"
 #include "test/helpers.hpp"
 
-#include 
-#include 
-
 /// Stress testing and performance/scalability benchmarking tool.
 
 class Stress: public Poco::Util::Application
@@ -115,7 +111,7 @@ public:
 
 private:
 Stress& _app;
-std::string _traceFilePath;
+TraceFileReader _traceFile;
 };
 
 Stress::Stress() :
diff --git a/loolwsd/TraceFile.hpp b/loolwsd/TraceFile.hpp
index 8c61d1f..73713e6 100644
--- a/loolwsd/TraceFile.hpp
+++ b/loolwsd/TraceFile.hpp
@@ -7,8 +7,9 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include 
 #include 
+#include 
+#include 
 
 /// Dumps commands and notification trace.
 class TraceFileWriter
@@ -53,4 +54,18 @@ private:
 std::mutex _mutex;
 };
 
+class TraceFileReader
+{
+public:
+TraceFileReader(const std::string& path) :
+_epochStart(Poco::Timestamp().epochMicroseconds()),
+_stream(path, std::ios::in)
+{
+}
+
+private:
+const Poco::Int64 _epochStart;
+std::fstream _stream;
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits