14 #ifndef MLPACK_CORE_UTILITIES_TIMERS_HPP 15 #define MLPACK_CORE_UTILITIES_TIMERS_HPP 28 #if !defined(HAVE_UINT64_T) 29 #if SIZEOF_UNSIGNED_LONG == 8 30 typedef unsigned long uint64_t;
32 typedef unsigned long long uint64_t;
33 #endif // SIZEOF_UNSIGNED_LONG 34 #endif // HAVE_UINT64_T 60 static void Start(
const std::string& name);
70 static void Stop(
const std::string& name);
77 static std::chrono::microseconds
Get(
const std::string& name);
107 std::map<std::string, std::chrono::microseconds> GetAllTimers();
121 std::chrono::microseconds GetTimer(
const std::string& timerName);
129 void PrintTimer(
const std::string& timerName);
140 void StartTimer(
const std::string& timerName,
141 const std::thread::id& threadId = std::thread::id());
149 void StopTimer(
const std::string& timerName,
150 const std::thread::id& threadId = std::thread::id());
158 bool GetState(
const std::string& timerName,
159 const std::thread::id& threadId = std::thread::id());
164 void StopAllTimers();
167 std::atomic<bool>&
Enabled() {
return enabled; }
173 std::map<std::string, std::chrono::microseconds> timers;
175 std::mutex timersMutex;
177 std::map<std::thread::id, std::map<std::string,
178 std::chrono::high_resolution_clock::time_point>> timerStartTime;
181 std::atomic<bool> enabled;
186 #endif // MLPACK_CORE_UTILITIES_TIMERS_HPP Timers()
Default to disabled.
Definition: timers.hpp:102
static void Start(const std::string &name)
Start the given timer.
Definition: timers.cpp:28
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
static std::chrono::microseconds Get(const std::string &name)
Get the value of the given timer.
Definition: timers.cpp:44
static void EnableTiming()
Enable timing of mlpack programs.
Definition: timers.cpp:50
Definition: timers.hpp:98
bool Enabled() const
Get whether or not timing is enabled.
Definition: timers.hpp:169
The timer class provides a way for mlpack methods to be timed.
Definition: timers.hpp:46
static void Stop(const std::string &name)
Stop the given timer.
Definition: timers.cpp:36
std::atomic< bool > & Enabled()
Modify whether or not timing is enabled.
Definition: timers.hpp:167
static void ResetAll()
Stop and reset all running timers.
Definition: timers.cpp:62
static void DisableTiming()
Disable timing of mlpack programs.
Definition: timers.cpp:56