From 46d3ace6b76ffbdb14473a5aed9a0636d176a7b9 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Tue, 1 Oct 2013 12:22:38 -0700 Subject: [PATCH] Fix JobQueue to measure waiting and run times correctly --- src/ripple_core/functional/Job.cpp | 6 +----- src/ripple_core/functional/Job.h | 2 -- src/ripple_core/functional/JobQueue.cpp | 3 --- src/ripple_core/functional/LoadEvent.cpp | 6 +++--- src/ripple_core/functional/LoadEvent.h | 4 ++-- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/ripple_core/functional/Job.cpp b/src/ripple_core/functional/Job.cpp index 5ac68f06a..305ece891 100644 --- a/src/ripple_core/functional/Job.cpp +++ b/src/ripple_core/functional/Job.cpp @@ -86,6 +86,7 @@ bool Job::shouldCancel () const void Job::doJob () { + m_loadEvent->start (); m_loadEvent->reName (mName); mJob (*this); @@ -96,11 +97,6 @@ void Job::rename (std::string const& newName) mName = newName; } -LoadEvent& Job::peekEvent() const -{ - return *m_loadEvent; -} - const char* Job::toString (JobType t) { switch (t) diff --git a/src/ripple_core/functional/Job.h b/src/ripple_core/functional/Job.h index 5037b6ab4..9169bc8f2 100644 --- a/src/ripple_core/functional/Job.h +++ b/src/ripple_core/functional/Job.h @@ -107,8 +107,6 @@ public: void rename (const std::string& n); - LoadEvent& peekEvent() const; - // These comparison operators make the jobs sort in priority order in the job set bool operator< (const Job& j) const; bool operator> (const Job& j) const; diff --git a/src/ripple_core/functional/JobQueue.cpp b/src/ripple_core/functional/JobQueue.cpp index 60b9296d4..8a41bc3c6 100644 --- a/src/ripple_core/functional/JobQueue.cpp +++ b/src/ripple_core/functional/JobQueue.cpp @@ -141,9 +141,6 @@ public: m_jobSet.insert (Job ( type, name, ++m_lastJob, m_loads[type], jobFunc, m_cancelCallback)); - // start timing how long it stays in the queue - it.first->peekEvent().start(); - queueJob (*it.first, lock); } } diff --git a/src/ripple_core/functional/LoadEvent.cpp b/src/ripple_core/functional/LoadEvent.cpp index f4c1b9c73..0c88bef40 100644 --- a/src/ripple_core/functional/LoadEvent.cpp +++ b/src/ripple_core/functional/LoadEvent.cpp @@ -21,7 +21,7 @@ LoadEvent::LoadEvent (LoadMonitor& monitor, const std::string& name, bool should : m_loadMonitor (monitor) , m_isRunning (false) , m_name (name) - , m_timeStopped (Time::getCurrentTime()) + , m_timeStopped (RelativeTime::fromStartup()) , m_secondsWaiting (0) , m_secondsRunning (0) { @@ -62,7 +62,7 @@ void LoadEvent::reName (const std::string& name) void LoadEvent::start () { - Time currentTime (Time::getCurrentTime()); + RelativeTime const currentTime (RelativeTime::fromStartup()); // If we already called start, this call will replace the previous one. if (m_isRunning) @@ -82,7 +82,7 @@ void LoadEvent::stop () { bassert (m_isRunning); - m_timeStopped = Time::getCurrentTime(); + m_timeStopped = RelativeTime::fromStartup(); m_secondsRunning += (m_timeStopped - m_timeStarted).inSeconds(); m_isRunning = false; diff --git a/src/ripple_core/functional/LoadEvent.h b/src/ripple_core/functional/LoadEvent.h index f6f96a0a0..5b0e5e565 100644 --- a/src/ripple_core/functional/LoadEvent.h +++ b/src/ripple_core/functional/LoadEvent.h @@ -71,8 +71,8 @@ private: LoadMonitor& m_loadMonitor; bool m_isRunning; std::string m_name; - Time m_timeStopped; - Time m_timeStarted; + RelativeTime m_timeStopped; + RelativeTime m_timeStarted; double m_secondsWaiting; double m_secondsRunning; };