| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
TimerForSequencer Class Reference

Auxilliary class. More...

`#include <TimerForSequencer.h>`

Collaboration diagram for TimerForSequencer:
[legend]

## Public Member Functions
| TimerForSequencer (const std::string &name, const unsigned int size, const double factor)
| Constructor.
| ~TimerForSequencer ()
void | start ()
| Start a time measurement.
double | stop ()
| Stop time measurement and return the last elapsed time.
const std::string & | name () const
| returns the name
double | lastTime () const
| returns the last measured time
double | lastCpu () const
| returns the last measured time
double | elapsedTotal () const
| returns the total elapsed time
double | cpuTotal () const
| returns the total cpu time
double | count () const
| Returns the number run count.
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
unsigned int | m_size
double | m_factor
long long | m_startClock
long long | m_startCpu
long 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 | ( | const std::string & | name,
|  | const unsigned int | size,
|  | const double | factor
| ) |  |
| inline

Constructor.

Specify the name, for later printing.

Definition at line 20 of file TimerForSequencer.h.

: m_name ( name ),
m_size ( size ),
m_factor ( factor ),
m_startClock ( 0LL ),
m_startCpu ( 0LL ),
m_num ( 0LL ),
m_lastTime ( 0. ),
m_lastCpu ( 0. ),
m_min ( 0. ),
m_max ( 0. ),
m_sum ( 0. ),
m_sumCpu ( 0. )
{ }

TimerForSequencer::~TimerForSequencer | ( |  | ) |
| inline

Definition at line 37 of file TimerForSequencer.h.

{}

## Member Function Documentation

double TimerForSequencer::count | ( |  | ) | const
| inline

Returns the number run count.

Definition at line 67 of file TimerForSequencer.h.

{ return (double)m_num; }

double TimerForSequencer::cpuTotal | ( |  | ) | const
| inline

returns the total cpu time

Definition at line 64 of file TimerForSequencer.h.

{ return m_sumCpu; }

double TimerForSequencer::elapsedTotal | ( |  | ) | const
| inline

returns the total elapsed time

Definition at line 61 of file TimerForSequencer.h.

{ return m_sum; }

MsgStream & TimerForSequencer::fillStream | ( | MsgStream & | s | ) | const

Write measured time into the message stream.

Definition at line 40 of file TimerForSequencer.cpp.

{
double ave = 0.;
double cpu = 0.;
if ( 0 != m_num )
{
ave = m_sum / m_num;
cpu = m_sumCpu / m_num;
}
return s << m_name.substr(0,m_size)
<< format( "| %9.3f | %9.3f | %8.3f %9.1f | %7d | %9.3f |",
cpu, ave, m_min, m_max, m_num, m_sum * 0.001 );
}

std::string TimerForSequencer::header | ( | std::string::size_type | size | ) |
| static

header matching the previous format

Definition at line 56 of file TimerForSequencer.cpp.

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

double TimerForSequencer::lastCpu | ( |  | ) | const
| inline

returns the last measured time

Definition at line 58 of file TimerForSequencer.h.

{ return m_lastCpu; }

double TimerForSequencer::lastTime | ( |  | ) | const
| inline

returns the last measured time

Definition at line 55 of file TimerForSequencer.h.

{ return m_lastTime; }

const std::string& TimerForSequencer::name | ( |  | ) | const
| inline

returns the name

Definition at line 52 of file TimerForSequencer.h.

{ return m_name; }

void TimerForSequencer::start | ( |  | ) |
| inline

Start a time measurement.

Definition at line 40 of file TimerForSequencer.h.

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

double TimerForSequencer::stop | ( |  | ) |

Stop time measurement and return the last elapsed time.

Returns
  Measured time in ms

Definition at line 11 of file TimerForSequencer.cpp.

{
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 79 of file TimerForSequencer.h.

double TimerForSequencer::m_lastCpu
| private

Definition at line 85 of file TimerForSequencer.h.

double TimerForSequencer::m_lastTime
| private

Definition at line 84 of file TimerForSequencer.h.

double TimerForSequencer::m_max
| private

Definition at line 87 of file TimerForSequencer.h.

double TimerForSequencer::m_min
| private

Definition at line 86 of file TimerForSequencer.h.

std::string TimerForSequencer::m_name
| private

Definition at line 77 of file TimerForSequencer.h.

long long TimerForSequencer::m_num
| private

Definition at line 83 of file TimerForSequencer.h.

unsigned int TimerForSequencer::m_size
| private

Definition at line 78 of file TimerForSequencer.h.

long long TimerForSequencer::m_startClock
| private

Definition at line 80 of file TimerForSequencer.h.

long long TimerForSequencer::m_startCpu
| private

Definition at line 81 of file TimerForSequencer.h.

double TimerForSequencer::m_sum
| private

Definition at line 88 of file TimerForSequencer.h.

double TimerForSequencer::m_sumCpu
| private

Definition at line 89 of file TimerForSequencer.h.

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

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