loolwsd/LOOLStress.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
New commits: commit a750edd70dda63a2dd5ca3c72641b207d4f45c99 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> 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 <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> 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 <unistd.h> #include <algorithm> +#include <chrono> #include <cstdlib> #include <cstring> #include <fstream> #include <iostream> #include <random> +#include <thread> #include <Poco/Net/NetException.h> #include <Poco/Net/HTTPRequest.h> @@ -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<std::chrono::microseconds>(delta).count(); + if (delay > 0) + { + std::this_thread::sleep_for(std::chrono::microseconds(delay)); + } + + helpers::sendTextFrame(socket, rec.Payload); + } } catch (const Poco::Exception &e) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits