Timer

This is a general class to compute the user processor time on parts of the program.

[ GAMB | Source | Keywords | Summary | Ancestors | All Members | Descendants ]

Quick Index

KEYWORD
AUTHORS
CHANGES LOG
USAGE

Class Summary

class Timer

{
public:
Timer();
Timer(const char* const tmID);
~Timer();
void reset();
void start();
void stop();
float operator()() const;
friend ostream& operator<<(ostream& out, const Timer& tm);
protected:
}; // Timer

Back to the top of Timer


KEYWORD

time, clock, clocks_per_sec

Back to the top of Timer


AUTHORS

Zipi Fligelman (zipo@math.tau.ac.il)

copyright: SAMBA Group , Tel-Aviv Univ. Israel, 1998.

Back to the top of Timer


CHANGES LOG

Back to the top of Timer


USAGE

Before an important code part you define a timer thus strating it. After starting it every time you will output it, it will compute the proc sec. passed between the construction of the Timer and the curr time. You can also stop the timer after the operation you wanted has finished. Stopping the clock means that every time you will output the class, you will only recieve the time that was set between start and finish. You can accumulate the time on different part of the program using the start and stop facilities, the time will be added together. Thus giving you exact information on running of the program without for example major debugging parts

first example:

    Timer timer("prog_time");
    ... doing preprocessing
    ... some debugging info 
    cout << timer; ( how much time preprocessing  & debugging took.)
    .... doing matching
    .... some debugging info
    cout << timer ; (how much time preprocessing , matching & debugging took.)
    .... doing verification
    cout << timer; (how much time the whole program took including debugging) 

second example:

    Timer timer("on_off_time");
    .... doing preprocessing
    timer.stop();
    .... som debugging info
    cout << timer; (how much time preprocessing took.)
    .... doing matching
    .... some debugging info
    cout << timer; (how much time preprocessing took.)
    .... doing verification
    cout << timer; (how much time preprocessing took.) 

third example:

    Timer timer("on_off_time");
    .... doing preprocessing
    timer.stop();
    .... some debugging info
    cout << timer; (how much time preprocessing took.)
    timer.start();
    .... doing matching
    cout << timer; (how much time only preprocessing and matching took.)
    timer.stop();
    .... some debugging info
    timer.start();
    .... doing verification
    cout << timer; (how much time preprocessing took.) 

Back to the top of Timer


Timer();

Empty constructor. Resetting the start to zero. Assuming null Id.

  Timer();

Back to the top of Timer


Timer(const char* const tmID);

special possibilty if you want to keep different timers and differentiate them by an ID

  Timer(const char* const tmID);

Back to the top of Timer


~Timer();

destructor

  ~Timer();

Back to the top of Timer


void reset();

resetting the time so clock will be current clock and sum of clocks will be zero

  void reset();

Back to the top of Timer


void start();

Enable the timer to continue after a stop operation has been performed

  void start();

Back to the top of Timer


void stop();

Stopping the timer operation

  void stop();

Back to the top of Timer


float operator()() const;

If the timer is stopped returning the sec of proc time accumalated in memory. Otherwise the time accumalated in memory and the time form the last start operation until present.

  float operator()() const;

Back to the top of Timer


friend ostream& operator<<(ostream& out, const Timer& tm);

printing the i.d and the time (on what time is printed see operator())

  friend ostream& operator<<(ostream& out, const Timer& tm);

Back to the top of Timer


All Members

public:
void reset();
void start();
void stop();
float operator()() const;
friend ostream& operator<<(ostream& out, const Timer& tm);
protected:

Back to the top of Timer


Ancestors

Class does not inherit from any other class.

Back to the top of Timer


Descendants

Class is not inherited by any others.

Back to the top of Timer


Generated from source by the Cocoon utilities on Sun Nov 15 13:35:26 2009 .

Report problems to jkotula@unimax.com