LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
misc::timer Class Reference

Timing nested tasks. More...

#include <timer.hh>

Collaboration diagram for misc::timer:

Classes

class  time
class  time_var

Public Member Functions

 timer ()
 timer (const timer &rhs)
 ~timer ()
void push (const std::string &name)
void push (int i)
void pop (const std::string &task_name)
void pop (int i)
void pop ()
 Stop the current task's timer(the last task pushed on the stack).
void dump (std::ostream &out=std::cerr)
void dump_on_destruction (std::ostream &out)
void name (int i, const std::string &task_name)
 Assign name task_name to task number i.
void start ()
void stop ()
timeroperator<< (const timer &rhs)
 Import timer.

Private Types

typedef std::map< const
std::string, time_var * > 
task_map_type

Private Member Functions

void timeinfo (long time, long total_time, std::ostream &out)
 Write formatted timing results on out.

Private Attributes

task_map_type tasksmap
 Time information associated to each task name.
std::stack< time_var * > tasks
 Stack of timed tasks.
std::map< int, std::string > intmap
time_var total
std::ostream * dump_stream

Static Private Attributes

static const long clocks_per_sec = sysconf(_SC_CLK_TCK)

Detailed Description

Timing nested tasks.

Member Typedef Documentation

typedef std::map<const std::string, time_var*> misc::timer::task_map_type
private

Constructor & Destructor Documentation

misc::timer::timer ( )
misc::timer::timer ( const timer rhs)

References precondition, tasks, and tasksmap.

misc::timer::~timer ( )

References dump(), dump_stream, pop(), stop(), tasks, and tasksmap.

Member Function Documentation

void misc::timer::dump ( std::ostream &  out = std::cerr)

Write results.

Parameters
outAn output stream, set to std::cerr by default.

References clocks_per_sec, misc::timer::time_var::elapsed, misc::timer::time::sys, tasksmap, timeinfo(), total, misc::timer::time::user, and misc::timer::time::wall.

Referenced by ~timer().

void misc::timer::dump_on_destruction ( std::ostream &  out)
inline

Enable automatic information dumping upon destruction of the timer on stream out.

References dump_stream.

Referenced by task::tasks::time_report().

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

Assign name task_name to task number i.

References intmap.

timer & misc::timer::operator<< ( const timer rhs)

Import timer.

Import tasks defined in rhs. The total execution time of rhs is ignored.

Precondition
No task should be running in rhs.

References intmap, precondition, tasks, and tasksmap.

void misc::timer::pop ( const std::string &  task_name)
inline

Stop the current task and ensure its name matches the string passed as argument.

Parameters
task_nameThe name of the task to stop.

References pop(), precondition, tasks, and tasksmap.

Referenced by liveness::InterferenceGraph::compute_liveness(), task::TaskRegister::execute(), and liveness::Liveness::Liveness().

void misc::timer::pop ( int  i)
inline
See Also
pop()
pop(const std::string name)

References intmap, and pop().

void misc::timer::pop ( )

Stop the current task's timer(the last task pushed on the stack).

References precondition, and tasks.

Referenced by pop(), and ~timer().

void misc::timer::push ( const std::string &  name)

Start a sub timer for a named task.

Parameters
namea constant string which is the task's name

References misc::timer::time_var::start(), tasks, and tasksmap.

Referenced by liveness::InterferenceGraph::compute_liveness(), task::TaskRegister::execute(), liveness::Liveness::Liveness(), main(), and push().

void misc::timer::push ( int  i)
inline

Start a sub timer with an integer corresponding to a task.

See Also
push()
name()

References intmap, precondition, and push().

void misc::timer::start ( )
inline

Start the timer.

See Also
stop()

References misc::timer::time_var::start(), and total.

Referenced by main().

void misc::timer::stop ( )
inline

Stop the timer.

See Also
start()

References misc::timer::time_var::stop(), and total.

Referenced by ~timer().

void misc::timer::timeinfo ( long  time,
long  total_time,
std::ostream &  out 
)
private

Write formatted timing results on out.

References clocks_per_sec.

Referenced by dump().

Member Data Documentation

const long misc::timer::clocks_per_sec = sysconf(_SC_CLK_TCK)
staticprivate

Number of clocks ticks per second, set according to the system timing function used.

Referenced by dump(), and timeinfo().

std::ostream* misc::timer::dump_stream
private

A potential stream onto which results are dumped when the timer is destroyed. If this pointer is null, no action is taken during the destruction of the timer.

Referenced by dump_on_destruction(), and ~timer().

std::map<int, std::string> misc::timer::intmap
private

Dictionnary mapping an integer to a task name.

See Also
push(int)

Referenced by name(), operator<<(), pop(), and push().

std::stack<time_var*> misc::timer::tasks
private

Stack of timed tasks.

Referenced by operator<<(), pop(), push(), timer(), and ~timer().

task_map_type misc::timer::tasksmap
private

Time information associated to each task name.

Referenced by dump(), operator<<(), pop(), push(), timer(), and ~timer().

time_var misc::timer::total
private

Total time measured by the timer.

See Also
start()
stop()

Referenced by dump(), start(), and stop().


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