GraphLab: Distributed Graph-Parallel API  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
graphlab::timer Class Reference

A simple class that can be used for benchmarking/timing up to microsecond resolution. More...

#include <graphlab/util/timer.hpp>

List of all members.

Public Member Functions

 timer ()
 The timer starts on construction but can be restarted by calling graphlab::timer::start.
void start ()
 Reset the timer.
double current_time () const
 Returns the elapsed time in seconds since graphlab::timer::start was last called.
double current_time_millis () const
 Returns the elapsed time in milliseconds since graphlab::timer::start was last called.

Static Public Member Functions

static double sec_of_day ()
 Get the number of seconds (as a floating point value) since the Unix Epoch.
static size_t usec_of_day ()
 Returns only the micro-second component of the time since the Unix Epoch.
static float approx_time_seconds ()
 Returns the time since program start.
static size_t approx_time_millis ()
 Returns the time since program start.
static void sleep (size_t sleeplen)
static void sleep_ms (size_t sleeplen)

Detailed Description

A simple class that can be used for benchmarking/timing up to microsecond resolution.

Standard Usage

The timer is used by calling graphlab::timer::start and then by getting the current time since start by calling graphlab::timer::current_time.

For example:

#include <graphlab.hpp>
timer.start();
// do something
std::cout << "Elapsed time: " << timer.current_time() << std::endl;

Fast approximate time

Calling current item in a tight loop can be costly and so we provide a faster less accurate timing primitive which reads a local time variable that is updated roughly every 100 millisecond. These are the graphlab::timer::approx_time_seconds and graphlab::timer::approx_time_millis.

Definition at line 67 of file timer.hpp.


Member Function Documentation

size_t graphlab::timer::approx_time_millis ( )
static

Returns the time since program start.

This value is only updated once every 100ms and is therefore approximate (but fast).

Precision of deciseconds

Definition at line 85 of file timer.cpp.

float graphlab::timer::approx_time_seconds ( )
static

Returns the time since program start.

This value is only updated once every 100ms and is therefore approximate (but fast).

Precision of deciseconds

Definition at line 78 of file timer.cpp.

double graphlab::timer::current_time ( ) const
inline

Returns the elapsed time in seconds since graphlab::timer::start was last called.

Returns:
time in seconds since graphlab::timer::start was called.

Definition at line 91 of file timer.hpp.

double graphlab::timer::current_time_millis ( ) const
inline

Returns the elapsed time in milliseconds since graphlab::timer::start was last called.

Returns:
time in milliseconds since graphlab::timer::start was called.

Definition at line 108 of file timer.hpp.

void graphlab::timer::sleep ( size_t  sleeplen)
static

Sleeps for sleeplen seconds

Definition at line 90 of file timer.cpp.

void graphlab::timer::sleep_ms ( size_t  sleeplen)
static

Sleeps for sleeplen milliseconds.

Definition at line 101 of file timer.cpp.


The documentation for this class was generated from the following files: