tools/Replay.hpp | 7 ++++++- wsd/TraceFile.hpp | 14 +++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-)
New commits: commit 53a8101331933254fe0845daa789a94611df54b6 Author: Ashod Nakashian <[email protected]> Date: Fri Feb 10 00:54:52 2017 -0500 wsd: log the trace file duration and each record before executing Change-Id: Ia5c21f01198de3dc655fe3bf247178dd04f5eaa7 Reviewed-on: https://gerrit.libreoffice.org/34113 Reviewed-by: Ashod Nakashian <[email protected]> Tested-by: Ashod Nakashian <[email protected]> diff --git a/tools/Replay.hpp b/tools/Replay.hpp index d5ed00b..99806ec 100644 --- a/tools/Replay.hpp +++ b/tools/Replay.hpp @@ -114,9 +114,12 @@ protected: { TraceFileReader traceFile(_uri); - auto epochFile(traceFile.getEpoch()); + auto epochFile(traceFile.getEpochStart()); auto epochCurrent(std::chrono::steady_clock::now()); + const auto replayDuration = (traceFile.getEpochEnd() - epochFile); + std::cout << "Replaying file [" << _uri << "] of " << replayDuration / 1000000. << " second length." << std::endl; + for (;;) { const auto rec = traceFile.getNextRecord(); @@ -139,6 +142,8 @@ protected: std::this_thread::sleep_for(std::chrono::microseconds(delay)); } + std::cout << rec.toString() << std::endl; + if (rec.Dir == TraceFileRecord::Direction::Event) { // Meta info about about an event. diff --git a/wsd/TraceFile.hpp b/wsd/TraceFile.hpp index 544adac..91f5a5e 100644 --- a/wsd/TraceFile.hpp +++ b/wsd/TraceFile.hpp @@ -45,6 +45,14 @@ public: { } + std::string toString() const + { + std::ostringstream oss; + oss << static_cast<char>(Dir) << Pid << static_cast<char>(Dir) + << SessionId << static_cast<char>(Dir) << Payload; + return oss.str(); + } + Direction Dir; unsigned TimestampNs; unsigned Pid; @@ -308,6 +316,7 @@ public: TraceFileReader(const std::string& path) : _compressed(path.size() > 2 && path.substr(path.size() - 2) == "gz"), _epochStart(0), + _epochEnd(0), _stream(path, _compressed ? std::ios::binary : std::ios::in), _inflater(_stream, Poco::InflatingStreamBuf::STREAM_GZIP), _index(0), @@ -322,7 +331,8 @@ public: _stream.close(); } - Poco::Int64 getEpoch() const { return _epochStart; } + Poco::Int64 getEpochStart() const { return _epochStart; } + Poco::Int64 getEpochEnd() const { return _epochEnd; } TraceFileRecord getNextRecord() { @@ -402,6 +412,7 @@ private: _indexOut = advance(-1, TraceFileRecord::Direction::Outgoing); _epochStart = _records[0].TimestampNs; + _epochEnd = _records[_records.size() - 1].TimestampNs; } static bool extractRecord(const std::string& s, TraceFileRecord& rec) @@ -459,6 +470,7 @@ private: private: const bool _compressed; Poco::Int64 _epochStart; + Poco::Int64 _epochEnd; std::ifstream _stream; Poco::InflatingInputStream _inflater; std::vector<TraceFileRecord> _records; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
