From d27ad6251c4fa35c107e08e143ed4ec958d7c84d Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 30 Sep 2013 04:04:43 -0700 Subject: [PATCH] Improve the display resolution of LoadMonitor samples --- src/ripple_core/functional/LoadEvent.cpp | 6 +++--- src/ripple_core/functional/LoadEvent.h | 10 +++++----- src/ripple_core/functional/LoadMonitor.cpp | 11 +++++++++-- src/ripple_core/functional/LoadMonitor.h | 2 ++ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/ripple_core/functional/LoadEvent.cpp b/src/ripple_core/functional/LoadEvent.cpp index 72e8f08a7..f4c1b9c73 100644 --- a/src/ripple_core/functional/LoadEvent.cpp +++ b/src/ripple_core/functional/LoadEvent.cpp @@ -40,17 +40,17 @@ std::string const& LoadEvent::name () const return m_name; } -std::size_t LoadEvent::getSecondsWaiting() const +double LoadEvent::getSecondsWaiting() const { return m_secondsWaiting; } -std::size_t LoadEvent::getSecondsRunning() const +double LoadEvent::getSecondsRunning() const { return m_secondsRunning; } -std::size_t LoadEvent::getSecondsTotal() const +double LoadEvent::getSecondsTotal() const { return m_secondsWaiting + m_secondsRunning; } diff --git a/src/ripple_core/functional/LoadEvent.h b/src/ripple_core/functional/LoadEvent.h index 21d742c50..f6f96a0a0 100644 --- a/src/ripple_core/functional/LoadEvent.h +++ b/src/ripple_core/functional/LoadEvent.h @@ -49,9 +49,9 @@ public: ~LoadEvent (); std::string const& name () const; - std::size_t getSecondsWaiting() const; - std::size_t getSecondsRunning() const; - std::size_t getSecondsTotal() const; + double getSecondsWaiting() const; + double getSecondsRunning() const; + double getSecondsTotal() const; // VFALCO TODO rename this to setName () or setLabel () void reName (const std::string& name); @@ -73,8 +73,8 @@ private: std::string m_name; Time m_timeStopped; Time m_timeStarted; - std::size_t m_secondsWaiting; - std::size_t m_secondsRunning; + double m_secondsWaiting; + double m_secondsRunning; }; #endif diff --git a/src/ripple_core/functional/LoadMonitor.cpp b/src/ripple_core/functional/LoadMonitor.cpp index 7a7e4b587..2575d904e 100644 --- a/src/ripple_core/functional/LoadMonitor.cpp +++ b/src/ripple_core/functional/LoadMonitor.cpp @@ -108,6 +108,13 @@ void LoadMonitor::addLatency (int latency) mLatencyMSPeak = latencyPeak; } +std::string LoadMonitor::printElapsed (double seconds) +{ + std::stringstream ss; + ss << (std::size_t (seconds * 1000 + 0.5)) << " ms"; + return ss.str(); +} + void LoadMonitor::addLoadSample (LoadEvent const& sample) { std::string const& name (sample.name()); @@ -116,8 +123,8 @@ void LoadMonitor::addLoadSample (LoadEvent const& sample) if (latency.inSeconds() > 0.5) { WriteLog ((latency.inSeconds() > 1.0) ? lsWARNING : lsINFO, LoadMonitor) - << "Job: " << name << " ExecutionTime: " << RelativeTime (sample.getSecondsRunning()) << - " WaitingTime: " << RelativeTime (sample.getSecondsWaiting()); + << "Job: " << name << " ExecutionTime: " << printElapsed (sample.getSecondsRunning()) << + " WaitingTime: " << printElapsed (sample.getSecondsWaiting()); } // VFALCO NOTE Why does 1 become 0? diff --git a/src/ripple_core/functional/LoadMonitor.h b/src/ripple_core/functional/LoadMonitor.h index 1653c7b22..5589206f9 100644 --- a/src/ripple_core/functional/LoadMonitor.h +++ b/src/ripple_core/functional/LoadMonitor.h @@ -46,6 +46,8 @@ public: bool isOver (); private: + static std::string printElapsed (double seconds); + void update (); typedef RippleMutex LockType;