| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# TimerForSequencer Class Reference

Auxilliary class. More...

`#include <TimerForSequencer.h>`

Collaboration diagram for TimerForSequencer:

[legend]

List of all members.

## Public Member Functions
| TimerForSequencer (std::string name, double factor)
| Constructor.
| ~TimerForSequencer ()
void | start ()
| Start a time measurement.
double | stop ()
| Stop time measurement and return the last elapsed time.
std::string | name () const
| returns the name
double | lastTime () const
| returns the last measured time
double | lastCpu () const
| returns the last measured time
MsgStream & | fillStream (MsgStream &s) const
| Write measured time into the message stream.
std::string | header () const
| header matching the previous format
## Private Attributes
std::string | m_name
double | m_factor
longlong | m_startClock
longlong | m_startCpu
long | m_num
double | m_lastTime
double | m_lastCpu
double | m_min
double | m_max
double | m_sum
double | m_sumCpu

## Detailed Description

Auxilliary class.

Measure the time between start and stop, and compute average, min and max. In fact, measure the cpu time, and the elapsed time but givesmin/max only for elapsed.

Author:
  O.Callot

Definition at line 14 of file TimerForSequencer.h.

## Constructor & Destructor Documentation

TimerForSequencer::TimerForSequencer | ( | std::string | name,
|  | double | factor |
| ) |  |  | `[inline]`

Constructor.

Specify the name, for later printing.

Definition at line 19 of file TimerForSequencer.h.

    00019                                                      {
    00020     m_name   = name;
    00021     m_num    = 0;
    00022     m_min    = 0;
    00023     m_max    = 0;
    00024     m_sum    = 0;
    00025     m_sumCpu = 0;
    00026     m_factor = factor;
    00027     m_lastTime = 0.;
    00028     m_lastCpu  = 0.;
    00029   }

TimerForSequencer::~TimerForSequencer | ( |  | ) | `[inline]`

Definition at line 31 of file TimerForSequencer.h.

    00031 {};

## Member Function Documentation

void TimerForSequencer::start | ( |  | ) | `[inline]`

Start a time measurement.

Definition at line 34 of file TimerForSequencer.h.

    00034                 {
    00035     m_startClock = System::currentTime( System::microSec );
    00036     m_startCpu   = System::cpuTime( System::microSec );
    00037   }

double TimerForSequencer::stop | ( |  | ) | `[inline]`

Stop time measurement and return the last elapsed time.

Returns:
  Measured time in ms

Definition at line 42 of file TimerForSequencer.h.

    00042                 {
    00043     double cpuTime  =  double(System::cpuTime( System::microSec ) - m_startCpu );
    00044     double lastTime =  double(System::currentTime( System::microSec ) - m_startClock );
    00045
    00046     //== Change to normalized millisecond
    00047     cpuTime  *= m_factor;
    00048     lastTime *= m_factor;
    00049
    00050     //== Update the counter
    00051     m_num    += 1;
    00052     m_sum    += lastTime;
    00053     m_sumCpu += cpuTime;
    00054
    00055     if ( 1 == m_num ) {
    00056       m_min = lastTime;
    00057       m_max = lastTime;
    00058     } else {
    00059       if ( lastTime < m_min ) m_min = lastTime;
    00060       if ( lastTime > m_max ) m_max = lastTime;
    00061     }
    00062     m_lastTime = lastTime;
    00063     m_lastCpu  = cpuTime;
    00064     return lastTime;
    00065   }

std::string TimerForSequencer::name | ( |  | ) | const`[inline]`

returns the name

Definition at line 68 of file TimerForSequencer.h.

    00068 { return m_name; }

double TimerForSequencer::lastTime | ( |  | ) | const`[inline]`

returns the last measured time

Definition at line 71 of file TimerForSequencer.h.

    00071 { return m_lastTime; }

double TimerForSequencer::lastCpu | ( |  | ) | const`[inline]`

returns the last measured time

Definition at line 74 of file TimerForSequencer.h.

    00074 { return m_lastCpu; }

MsgStream& TimerForSequencer::fillStream | ( | MsgStream & | s | ) | const`[inline]`

Write measured time into the message stream.

Definition at line 77 of file TimerForSequencer.h.

    00077                                               {
    00078     double ave = 0.;
    00079     double cpu = 0.;
    00080
    00081     if ( 0 != m_num ) {
    00082       ave = m_sum    / m_num;
    00083       cpu = m_sumCpu / m_num;
    00084     }
    00085
    00086     return s << m_name
    00087              << format( "| %9.3f | %9.3f | %8.3f %9.1f | %7d | %9.3f |",
    00088                         cpu, ave, m_min, m_max, m_num, m_sum * 0.001 );
    00089   }

std::string TimerForSequencer::header | ( |  | ) | const`[inline]`

header matching the previous format

Definition at line 92 of file TimerForSequencer.h.

    00092                             {
    00093     std::string s = "Algorithm          (millisec) |    <user> |   <clock> |";
    00094     s += "      min       max | entries | total (s) |";
    00095     return s;
    00096   }

## Member Data Documentation

std::string TimerForSequencer::m_name`[private]`

Definition at line 99 of file TimerForSequencer.h.

double TimerForSequencer::m_factor`[private]`

Definition at line 100 of file TimerForSequencer.h.

longlong TimerForSequencer::m_startClock`[private]`

Definition at line 101 of file TimerForSequencer.h.

longlong TimerForSequencer::m_startCpu`[private]`

Definition at line 102 of file TimerForSequencer.h.

long TimerForSequencer::m_num`[private]`

Definition at line 104 of file TimerForSequencer.h.

double TimerForSequencer::m_lastTime`[private]`

Definition at line 105 of file TimerForSequencer.h.

double TimerForSequencer::m_lastCpu`[private]`

Definition at line 106 of file TimerForSequencer.h.

double TimerForSequencer::m_min`[private]`

Definition at line 107 of file TimerForSequencer.h.

double TimerForSequencer::m_max`[private]`

Definition at line 108 of file TimerForSequencer.h.

double TimerForSequencer::m_sum`[private]`

Definition at line 109 of file TimerForSequencer.h.

double TimerForSequencer::m_sumCpu`[private]`

Definition at line 110 of file TimerForSequencer.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/GaudiAlg/src/components/TimerForSequencer.h