| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Public Member Functions | Static Public Member Functions | Private Attributes

# 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.
## Static Public Member Functions
static std::string | header (std::string::size_type size)
| 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.

                                                         {
        m_name   = name;
        m_num    = 0;
        m_min    = 0;
        m_max    = 0;
        m_sum    = 0;
        m_sumCpu = 0;
        m_factor = factor;
        m_lastTime = 0.;
        m_lastCpu  = 0.;
      }

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

Definition at line 31 of file TimerForSequencer.h.

    {};

## Member Function Documentation

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

Write measured time into the message stream.

Definition at line 77 of file TimerForSequencer.h.

                                                  {
        double ave = 0.;
        double cpu = 0.;

        if ( 0 != m_num ) {
          ave = m_sum    / m_num;
          cpu = m_sumCpu / m_num;
        }

        return s << m_name
                 << format( "| %9.3f | %9.3f | %8.3f %9.1f | %7d | %9.3f |",
                            cpu, ave, m_min, m_max, m_num, m_sum * 0.001 );
      }

static std::string TimerForSequencer::header | ( | std::string::size_type | size ) | `[inline, static]`

header matching the previous format

Definition at line 92 of file TimerForSequencer.h.

                                                         {
        if ( size < 21 ) size = 21;
        std::string blank( size - 20, ' ' );
        std::string s = "Algorithm" + blank + "(millisec) |    <user> |   <clock> |";
        s += "      min       max | entries | total (s) |";
        return s;
      }

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

returns the last measured time

Definition at line 74 of file TimerForSequencer.h.

    { return m_lastCpu; }

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

returns the last measured time

Definition at line 71 of file TimerForSequencer.h.

    { return m_lastTime; }

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

returns the name

Definition at line 68 of file TimerForSequencer.h.

    { return m_name; }

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

Start a time measurement.

Definition at line 34 of file TimerForSequencer.h.

                    {
        m_startClock = System::currentTime( System::microSec );
        m_startCpu   = System::cpuTime( System::microSec );
      }

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.

                    {
        double cpuTime  =  double(System::cpuTime( System::microSec ) - m_startCpu );
        double lastTime =  double(System::currentTime( System::microSec ) - m_startClock );

        //== Change to normalized millisecond
        cpuTime  *= m_factor;
        lastTime *= m_factor;

        //== Update the counter
        m_num    += 1;
        m_sum    += lastTime;
        m_sumCpu += cpuTime;

        if ( 1 == m_num ) {
          m_min = lastTime;
          m_max = lastTime;
        } else {
          if ( lastTime < m_min ) m_min = lastTime;
          if ( lastTime > m_max ) m_max = lastTime;
        }
        m_lastTime = lastTime;
        m_lastCpu  = cpuTime;
        return lastTime;
      }

## Member Data Documentation

double TimerForSequencer::m_factor`[private]`

Definition at line 102 of file TimerForSequencer.h.

double TimerForSequencer::m_lastCpu`[private]`

Definition at line 108 of file TimerForSequencer.h.

double TimerForSequencer::m_lastTime`[private]`

Definition at line 107 of file TimerForSequencer.h.

double TimerForSequencer::m_max`[private]`

Definition at line 110 of file TimerForSequencer.h.

double TimerForSequencer::m_min`[private]`

Definition at line 109 of file TimerForSequencer.h.

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

Definition at line 101 of file TimerForSequencer.h.

long TimerForSequencer::m_num`[private]`

Definition at line 106 of file TimerForSequencer.h.

longlong TimerForSequencer::m_startClock`[private]`

Definition at line 103 of file TimerForSequencer.h.

longlong TimerForSequencer::m_startCpu`[private]`

Definition at line 104 of file TimerForSequencer.h.

double TimerForSequencer::m_sum`[private]`

Definition at line 111 of file TimerForSequencer.h.

double TimerForSequencer::m_sumCpu`[private]`

Definition at line 112 of file TimerForSequencer.h.

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

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines