From eac547a6c25a959b780cfd78cd8bee2ae03d08d1 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Mon, 14 Mar 2016 13:43:56 -0700 Subject: [PATCH] Refactor: remove once-used function, wrap lines. --- src/mlpack/core/util/timers.cpp | 9 ++------- src/mlpack/core/util/timers.hpp | 7 ++++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/mlpack/core/util/timers.cpp b/src/mlpack/core/util/timers.cpp index 25a8fc4684..fa0fd60647 100644 --- a/src/mlpack/core/util/timers.cpp +++ b/src/mlpack/core/util/timers.cpp @@ -14,12 +14,6 @@ using namespace mlpack; -inline std::chrono::microseconds getTimeDuration(const std::chrono::high_resolution_clock::time_point start, - const std::chrono::high_resolution_clock::time_point end) -{ - return std::chrono::duration_cast(end - start); -} - /** * Start the given timer. */ @@ -166,5 +160,6 @@ void Timers::StopTimer(const std::string& timerName) std::chrono::high_resolution_clock::time_point currTime = GetTime(); // Calculate the delta time. - timers[timerName] += getTimeDuration(timerStartTime[timerName], currTime); + timers[timerName] += std::chrono::duration_cast( + currTime - timerStartTime[timerName]) } diff --git a/src/mlpack/core/util/timers.hpp b/src/mlpack/core/util/timers.hpp index 205549cd74..2f1c2bf090 100644 --- a/src/mlpack/core/util/timers.hpp +++ b/src/mlpack/core/util/timers.hpp @@ -110,18 +110,19 @@ class Timers /** * Returns state of the given timer. - * + * * @param timerName The name of the timer in question. */ bool GetState(std::string timerName); - + private: //! A map of all the timers that are being tracked. std::map timers; //! A map that contains whether or not each timer is currently running. std::map timerState; //! A map for the starting values of the timers. - std::map timerStartTime; + std::map + timerStartTime; std::chrono::high_resolution_clock::time_point GetTime(); };