| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# TimerForSequencer Class Reference

`#include <TimerForSequencer.h>`

Collaboration diagram for TimerForSequencer:

[legend]
List of all members.

## 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.

## 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

## 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.

References m_factor, m_lastCpu, m_lastTime, m_max, m_min, m_name, m_num, m_sum, m_sumCpu, and name().

    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.

References System::cpuTime(), System::currentTime(), m_startClock, m_startCpu, and System::microSec.

Referenced by SequencerTimerTool::initialize().

    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.

References System::cpuTime(), System::currentTime(), lastTime(), m_factor, m_lastCpu, m_lastTime, m_max, m_min, m_num, m_startClock, m_startCpu, m_sum, m_sumCpu, and System::microSec.

Referenced by SequencerTimerTool::initialize().

    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.

References m_name.

Referenced by TimerForSequencer().

    00068 { return m_name; }

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

returns the last measured time

Definition at line 71 of file TimerForSequencer.h.

References m_lastTime.

Referenced by stop().

    00071 { return m_lastTime; }

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

returns the last measured time

Definition at line 74 of file TimerForSequencer.h.

References m_lastCpu.

Referenced by SequencerTimerTool::initialize().

    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.

References format(), m_max, m_min, m_name, m_num, m_sum, m_sumCpu, and Gaudi::Units::s.

Referenced by operator<<().

    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.

References Gaudi::Units::s.

    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.

Referenced by fillStream(), name(), and TimerForSequencer().

double TimerForSequencer::m_factor`[private]`

Definition at line 100 of file TimerForSequencer.h.

Referenced by stop(), and TimerForSequencer().

longlong TimerForSequencer::m_startClock`[private]`

Definition at line 101 of file TimerForSequencer.h.

Referenced by start(), and stop().

longlong TimerForSequencer::m_startCpu`[private]`

Definition at line 102 of file TimerForSequencer.h.

Referenced by start(), and stop().

long TimerForSequencer::m_num`[private]`

Definition at line 104 of file TimerForSequencer.h.

Referenced by fillStream(), stop(), and TimerForSequencer().

double TimerForSequencer::m_lastTime`[private]`

Definition at line 105 of file TimerForSequencer.h.

Referenced by lastTime(), stop(), and TimerForSequencer().

double TimerForSequencer::m_lastCpu`[private]`

Definition at line 106 of file TimerForSequencer.h.

Referenced by lastCpu(), stop(), and TimerForSequencer().

double TimerForSequencer::m_min`[private]`

Definition at line 107 of file TimerForSequencer.h.

Referenced by fillStream(), stop(), and TimerForSequencer().

double TimerForSequencer::m_max`[private]`

Definition at line 108 of file TimerForSequencer.h.

Referenced by fillStream(), stop(), and TimerForSequencer().

double TimerForSequencer::m_sum`[private]`

Definition at line 109 of file TimerForSequencer.h.

Referenced by fillStream(), stop(), and TimerForSequencer().

double TimerForSequencer::m_sumCpu`[private]`

Definition at line 110 of file TimerForSequencer.h.

Referenced by fillStream(), stop(), and TimerForSequencer().

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

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