mlpack: a scalable c++ machine learning library
mlpack  1.0.6
mlpack Timers


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 the mlpack::CLI object, when –verbose is given:

$ allknn -i=data.csv -k 5
[INFO ] Program timers:
[INFO ] computing_neighbors: 0.044764s
[INFO ] total_time: 0.061249s
[INFO ] tree_building: 0.003075s

Timer API

The mlpack::Timer class provides three simple methods:

void Timer::Start(const char* name);
void Timer::Stop(const char* name);
timeval Timer::Get(const char* name);

Each timer is given a name, and is referenced by that name.

A "total_time" timer is run by default for each mlpack program.

Timer Example

Below is a very simple example of timer usage in code.

#include <mlpack/core.hpp>
using namespace mlpack;
int main(int argc, char** argv)
CLI::ParseCommandLine(argc, argv);
// Start a timer.
// Do some things.
// Stop the timer.

If the –verbose flag was given to this executable, the resultant time that "some_timer" ran for would be shown.