Source: src/include/ArichChrono.hh
|
|
|
|
// -*- Mode: C++ -*-
#ifndef CHRONO_HH_
#define CHRONO_HH_
#include
#include
//#include
/*
CLASS
ArichChrono
Base concrete class used to evaluate time intervals between a
start() message and a stop() one. Usefull to measure time performances
of pieces of code.
RESPONSABILITIES:
Keep track of the CPU, kernel, user and elapsed time to perform actions.
It keep also track of how many times the chrono is activated.
It is responsible of printing information on request.
It should check for bad calling sequences: e.g. start, start;
or stop, stop; or stop, start ...
OPERATIONS:
start()
stop()
reset()
lastTime()
print()
DATA STORED
number of Start/Stop received
Cumulative stored time
Start time at the Start signal
WARNING
This class can be system-dependent. It has been checked on HP.
*/
class ArichChrono {
public:
//-- Constructors
// Constructors: they need a name for the ArichChrono that can be defined
// both by a string or by an array of characters
ArichChrono(char *s);
//--
// Constructor wit chrono name given by a string
// ArichChrono(string & s);
//-- Destructor
// Destructor: currently void
~ArichChrono();
//-- Behavioural operations
// Reset counters and stored time
void reset();
//--
// Start a counting measuring time operation
void start();
//--
// Stop a measuring time operation
void stop();
// Access functions
//--
// Inquire for the last total time measured
inline float lastTime() const;
//--
// Print all information for the current ArichChrono.
void print() const;
//--
// Print all infos in a single line. To be used with the
// ArichChronoManager class.
void printLine() const;
//--
// Get the number of measurements made.
inline int timesMeasured() const;
//--
// Get the average time (user+system) for the measurements if
// 2 or more measurements have been made, 0 otherwise.
inline float averageTime() const;
protected:
//--
// the Default constructor is protected to avoid copying and uncontrolled
// creation operation
ArichChrono();
//--
// Evaluate times in seconds: private member function
void evaluateSeconds(float & totaltime, float & usertime,
float & systemtime,float & avtottime,
float & avustime, float &avsystime) const;
private:
///////////////////// Data Part /////////////////////////////////
//--
// ArichChrono name
char chronoName[15];
//--
// Store the total number of measurements made
int numberOfMeasurements;
//--
// Store total user and kernel time used by the process
clock_t total_utime;
clock_t total_stime;
//-- Store starting time for the current measurement
clock_t start_utime;
clock_t start_stime;
//-- Conversion factor from clock ticks to seconds
// time(seconds) = rclk_tck * time(clock_ticks)
static float rclk_tck;
};
#include "ArichChrono.icc"
#endif // CHRONO_HH_
Generated by: rok on f9pc43.ijs.si on Wed Jun 18 12:02:34 2003, using kdoc 2.0a54. |