mlpack provides a simple timer interface for the timing of machine learning methods. The results of any timers used during the program are displayed at output by any command-line binding, when –verbose is given:
The mlpack::Timer class provides three simple methods:
Each timer is given a name, and is referenced by that name. You can call Timer::Start()
and Timer::Stop()
multiple times for a particular timer name, and the result will be the sum of the runs of the timer. Note that Timer::Stop()
must be called before Timer::Start()
is called again, otherwise a std::runtime_error exception will be thrown.
A "total_time"
timer is run by default for each mlpack program.
Below is a very simple example of timer usage in code.
If the –verbose flag was given to this executable, the time that "some_timer"
ran for would be printed at the end of the program's output.