- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# col::NanoTimer Class Reference

Timer with nanoseconds resolution. More...

Collaboration diagram for col::NanoTimer:

[legend]
List of all members.

## Timers, timing, sleeping, etc.
| NanoTimer ()
| Create a new timer with nanoseconds resolution.
void | start (void)
| Save the current time (stamp) in the timer.
double | elapsed (void) const
| Return the time elapsed since the last start() in nanoseconds.
static bool | usesHighFrequ (void)
| Tells whether or not the NanoTimer use the high frequency counter.
static double | frequ (void)
| Returns the frequency (resolution) of the counter in GHz.

## Detailed Description

Timer with nanoseconds resolution.

The units of this timer are always nanoseconds, but on some platforms, the actual resolution might be less (microseconds or even less).

Where implemented, this class uses the high-speed, high-performance, hardware timers/counters. Otherwise, we just use gettimeofday(), which, at least on Linux/Pentium, has microsecond resolution.

Currently, the time is wall-clock time, not user time!

See also:
  - http://www.ncsa.uiuc.edu/UserInfo/Resources/Hardware/IA32LinuxCluster/Doc/timing.html
  - cedar.intel.com/software/idap/media/pdf/rdtscpm1.pdf
  - /raphael/knowledge/programming/c/code-snippets/cpu_clock_timer.c

Todo:
  - Try to estimate the overhead of a function call to start() or elapsed().
  - Use PAPI (http://icl.cs.utk.edu/projects/papi/) or the "high resolution timers project" (http://high-res-timers.sourceforge.net/) when they become widely available (without kernel patches).

## Constructor & Destructor Documentation

col::NanoTimer::NanoTimer | ( | void |  | ) |

Create a new timer with nanoseconds resolution.

Saves the current time stamp, too.

Sideeffects:
  See checkFrequency().

## Member Function Documentation

bool col::NanoTimer::usesHighFrequ | ( | void |  | ) | `[static]`

Tells whether or not the NanoTimer use the high frequency counter.

Warning:
  Valid only after the first NanoTimer has been created!

double col::NanoTimer::frequ | ( | void |  | ) | `[static]`

Returns the frequency (resolution) of the counter in GHz.

Warning:
  Valid only if NanoTimer::usesHighFrequ() = true !

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

- ColUtils.h
- ColUtils.cpp