The timer class provides a way for mlpack methods to be timed. More...

Static Public Member Functions

static void DisableTiming ()
 Disable timing of mlpack programs. More...

 
static void EnableTiming ()
 Enable timing of mlpack programs. More...

 
static std::chrono::microseconds Get (const std::string &name)
 Get the value of the given timer. More...

 
static std::map< std::string, std::chrono::microseconds > GetAllTimers ()
 Returns a copy of all the timers used via this interface. More...

 
static void ResetAll ()
 Stop and reset all running timers. More...

 
static void Start (const std::string &name)
 Start the given timer. More...

 
static void Stop (const std::string &name)
 Stop the given timer. More...

 

Detailed Description

The timer class provides a way for mlpack methods to be timed.

The three methods contained in this class allow a named timer to be started and stopped, and its value to be obtained. A named timer is specific to the thread it is running on, so if you start a timer in one thread, it cannot be stopped from a different thread.

Definition at line 46 of file timers.hpp.

Member Function Documentation

◆ DisableTiming()

static void DisableTiming ( )
static

Disable timing of mlpack programs.

Do not run this while timers are running!

◆ EnableTiming()

static void EnableTiming ( )
static

Enable timing of mlpack programs.

Do not run this while timers are running!

Referenced by mlpack::util::EnableTimers(), mlpack::util::GetParamWithInfo(), and main().

◆ Get()

static std::chrono::microseconds Get ( const std::string &  name)
static

Get the value of the given timer.

Parameters
nameName of timer to return value of.

Referenced by Timers::Timers().

◆ GetAllTimers()

static std::map<std::string, std::chrono::microseconds> GetAllTimers ( )
static

Returns a copy of all the timers used via this interface.

Referenced by mlpack::bindings::cli::EndProgram(), and Timers::Timers().

◆ ResetAll()

static void ResetAll ( )
static

Stop and reset all running timers.

This removes all knowledge of any existing timers.

Referenced by mlpack::util::GetParamWithInfo(), and mlpack::util::ResetTimers().

◆ Start()

static void Start ( const std::string &  name)
static

Start the given timer.

If a timer is started, then stopped, then re-started, then re-stopped, the final value of the timer is the length of both runs – that is, mlpack timers are additive for each time they are run, and do not reset.

Note
A std::runtime_error exception will be thrown if a timer is started twice.
Parameters
nameName of timer to be started.

Referenced by Timers::Timers().

◆ Stop()

static void Stop ( const std::string &  name)
static

Stop the given timer.

Note
A std::runtime_error exception will be thrown if a timer is started twice.
Parameters
nameName of timer to be stopped.

Referenced by Timers::Timers().


The documentation for this class was generated from the following file:
  • /home/ryan/src/mlpack.org/_src/mlpack-git/src/mlpack/core/util/timers.hpp