Timer Class Reference

Timing nested tasks. More...

List of all members.

Public Types

typedef std::map< const std::string,
TimeVar
task_map_type

Public Member Functions

void push (const std::string &name)
 Start a sub-timer for a named task.
void push (const int i)
 Start a sub-timer with an integer which refers to a string.
void pop (const std::string &task_name)
 Stop the named task.
void pop (const int i)
 
See also:
pop (), pop (const std::string name)

void pop ()
 Stop the current task's timer (the last task pushed).
std::ostream & print (std::ostream &o, const bool) const
 Write results.
void print_on_destruction (std::ostream &out)
 Write results when the timer is destroyed.
void name (int i, const std::string &name)
 The name function links an int and a constant string.
void start ()
 The start function must be called at the beginning of the program to get the total time spend in the whole program.
void stop ()
 The stop function must be called at the end of the program.
Timeroperator<< (const Timer &rhs)
 Import timer.
Timeroperator+= (const Timer &rhs)
 Accumulate another timer.
Timeroperator/= (unsigned rhs)
 Divide in place.
Timer operator/ (unsigned rhs) const
 Divide.
bool operator< (const Timer &rhs) const
 Comparison between two Timers.
void clear ()
 Reset all timers to zero.
TimeVaroperator[] (const std::string &s)
std::ostream & print_time (long t, long total, std::ostream &o) const
 Format timing results.
std::ostream & print_time (std::string s, const Time &t, const Time &tot, std::ostream &o, const bool tree_mode) const
 Print statistics on a Time.

Friends

class Bencher

Classes

class  Time
 User, system and wall clock time convenient interface. More...
class  TimeVar
 An actual sub-timer. More...


Detailed Description

Timing nested tasks.

Definition at line 51 of file timer.hh.


Member Function Documentation

void push ( const std::string &  name  ) 

Start a sub-timer for a named task.

Parameters:
name a constant string which is the task's name

Referenced by Timer::push(), and ScopedTimer::ScopedTimer().

void push ( const int  i  )  [inline]

Start a sub-timer with an integer which refers to a string.

See also:
push (), name ()

Definition at line 39 of file timer.hxx.

References precondition, and Timer::push().

void pop ( const std::string &  task_name  )  [inline]

Stop the named task.

Take a const string as parameter that make sure that what is popped is indeed what is on top.

Definition at line 47 of file timer.hxx.

References Timer::pop(), and precondition.

Referenced by ScopedTimer::~ScopedTimer().

std::ostream& print ( std::ostream &  o,
const   bool 
) const

Write results.

Parameters:
o an ostream.

void print_on_destruction ( std::ostream &  out  )  [inline]

Write results when the timer is destroyed.

Parameters:
out an ostream which defaults to cerr.

Definition at line 63 of file timer.hxx.

void name ( int  i,
const std::string &  name 
)

The name function links an int and a constant string.

Parameters:
i the integer key to register
name the associated task name

void start (  )  [inline]

The start function must be called at the beginning of the program to get the total time spend in the whole program.

See also:
stop ()

Definition at line 70 of file timer.hxx.

References Timer::TimeVar::start().

void stop (  )  [inline]

The stop function must be called at the end of the program.

See also:
start ()

Definition at line 77 of file timer.hxx.

References Timer::TimeVar::stop().

Timer& operator<< ( const Timer rhs  ) 

Import timer.

Import tasks defined in rhs. There must be not stacked task. Total execution time of rhs is ignored.

bool operator< ( const Timer rhs  )  const [inline]

Comparison between two Timers.

This operators enables the use of std::min and std::max. It check only the total time, so it's a strict weak ordering.

Definition at line 104 of file timer.hxx.

References Timer::total.

std::ostream& print_time ( std::string  s,
const Time t,
const Time tot,
std::ostream &  o,
const bool  tree_mode 
) const

Print statistics on a Time.

Parameters:
s title
t Time to report
tot total Time t is a part of
o output stream
tree_mode Activate tree mode display


Generated on Wed Jun 13 17:03:19 2007 for Vaucanson by  doxygen 1.5.1