Refactor: remove once-used function, wrap lines.
This commit is contained in:
@@ -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<std::chrono::microseconds>(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<std::chrono::microseconds>(
|
||||
currTime - timerStartTime[timerName])
|
||||
}
|
||||
|
||||
@@ -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<std::string, std::chrono::microseconds> timers;
|
||||
//! A map that contains whether or not each timer is currently running.
|
||||
std::map<std::string, bool> timerState;
|
||||
//! A map for the starting values of the timers.
|
||||
std::map<std::string, std::chrono::high_resolution_clock::time_point> timerStartTime;
|
||||
std::map<std::string, std::chrono::high_resolution_clock::time_point>
|
||||
timerStartTime;
|
||||
|
||||
std::chrono::high_resolution_clock::time_point GetTime();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user