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

# SequencerTimerTool Class Reference

`#include <SequencerTimerTool.h>`

Inheritance diagram for SequencerTimerTool:

[legend]
Collaboration diagram for SequencerTimerTool:

[legend]
List of all members.

## Detailed Description

Implements the time measurement inside a sequencer.

Author:
  Olivier Callot

Date:
  2004-05-19

Definition at line 21 of file SequencerTimerTool.h.

## Public Member Functions
| SequencerTimerTool (const std::string &type, const std::string &name, const IInterface *parent)
| Standard constructor.
virtual | ~SequencerTimerTool ()
| Destructor.
virtual StatusCode | initialize ()
| initialize method, to compute the normalisation factor
virtual StatusCode | finalize ()
| finalize method, to print the time summary table
virtual int | addTimer (std::string name)
| add a timer entry with the specified name
virtual void | increaseIndent ()
| Increase the indentation of the name.
virtual void | decreaseIndent ()
| Decrease the indentation fo the name.
void | start (int index)
| start the counter, i.e.
double | stop (int index)
| stop the counter, return the elapsed time
double | lastTime (int index)
| returns the last time
std::string | name (int index)
| returns the name of the counter
int | indexByName (std::string name)
| returns the index of the counter with that name, or -1
virtual bool | globalTiming ()
| returns the flag telling that global timing is wanted
## Private Attributes
int | m_shots
| Number of shots for CPU normalisation.
bool | m_normalised
| Is the time scaled to a nominal PIII ?
int | m_indent
| Amount of indentation.
std::vector< TimerForSequencer > | m_timerList
double | m_normFactor
| Factor to convert to standard CPU (1 GHz PIII).
double | m_speedRatio
bool | m_globalTiming

## Constructor & Destructor Documentation

SequencerTimerTool::SequencerTimerTool | ( | const std::string & | type,
|  | const std::string & | name,
|  | const IInterface * | parent |
| ) |  |  |

Standard constructor.

Definition at line 24 of file SequencerTimerTool.cpp.

    00027   : GaudiTool ( type, name , parent )
    00028   , m_indent( 0 )
    00029   , m_normFactor( 0.001 )
    00030 {
    00031   declareInterface<ISequencerTimerTool>(this);
    00032
    00033   m_shots = 3500000 ; // 1s on 2.8GHz Xeon, gcc 3.2, -o2
    00034   declareProperty( "shots"        , m_shots );
    00035   declareProperty( "Normalised"   , m_normalised = false );
    00036   declareProperty( "GlobalTiming" , m_globalTiming = false );
    00037 }

SequencerTimerTool::~SequencerTimerTool | ( |  | ) | `[virtual]`

Destructor.

Definition at line 41 of file SequencerTimerTool.cpp.

    00041 {};

## Member Function Documentation

StatusCode SequencerTimerTool::initialize | ( |  | ) | `[virtual]`

initialize method, to compute the normalisation factor

Reimplemented from GaudiTool.

Definition at line 47 of file SequencerTimerTool.cpp.

References endreq(), format(), Gaudi::Units::gauss, GaudiCommon< AlgTool >::info(), GaudiTool::initialize(), TimerForSequencer::lastCpu(), m_normalised, m_normFactor, m_shots, m_speedRatio, TimerForSequencer::start(), TimerForSequencer::stop(), and StatusCode::SUCCESS.

    00047                                             {
    00048   GaudiTool::initialize();
    00049   double sum = 0;
    00050   TimerForSequencer norm( "normalize", m_normFactor );
    00051   norm.start();
    00052   IRndmGenSvc* rsvc = svc<IRndmGenSvc>( "RndmGenSvc", true );
    00053   { // Use dummy loop suggested by Vanya Belyaev:
    00054     Rndm::Numbers gauss;
    00055     gauss.initialize( rsvc , Rndm::Gauss(0.,1.0) ).ignore();
    00056     unsigned int shots = m_shots;
    00057     while( 0 < --shots ) { sum += gauss() * sum ; }
    00058   }
    00059   norm.stop();
    00060   double time = norm.lastCpu();
    00061   m_speedRatio = 1./time;
    00062   info() << "This machine has a speed about "
    00063          << format( "%6.2f", 1000.*m_speedRatio)
    00064          << " times the speed of a 2.8 GHz Xeon." << endreq ;
    00065    if ( m_normalised ) {
    00066     m_normFactor = m_speedRatio;
    00067   }
    00068   return StatusCode::SUCCESS;
    00069 }

StatusCode SequencerTimerTool::finalize | ( |  | ) | `[virtual]`

finalize method, to print the time summary table

Reimplemented from GaudiTool.

Definition at line 73 of file SequencerTimerTool.cpp.

References endreq(), GaudiTool::finalize(), format(), GaudiCommon< AlgTool >::info(), m_normalised, m_speedRatio, m_timerList, AlgTool::name(), and std::vector< _Tp, _Alloc >::size().

    00073                                           {
    00074
    00075   std::string line(96, '-');
    00076   info() << line << endreq
    00077          << "This machine has a speed about "
    00078          << format( "%6.2f", 1000.*m_speedRatio)
    00079          << " times the speed of a 2.8 GHz Xeon.";
    00080   if ( m_normalised ) info() <<" *** All times are renormalized ***";
    00081   info() << endreq << m_timerList[0].header() << endreq
    00082          << line << endreq;
    00083
    00084   std::string lastName = "";
    00085   for ( unsigned int kk=0 ; m_timerList.size() > kk ; kk++ ) {
    00086     if ( lastName == m_timerList[kk].name() ) continue; // suppress duplicate
    00087     lastName = m_timerList[kk].name();
    00088     info() << m_timerList[kk] << endreq;
    00089   }
    00090   info() << line << endreq;
    00091
    00092   return GaudiTool::finalize();
    00093 }

virtual int SequencerTimerTool::addTimer | ( | std::string | name | ) | `[inline, virtual]`

add a timer entry with the specified name

Implements ISequencerTimerTool.

Definition at line 38 of file SequencerTimerTool.h.

References m_indent, m_normFactor, m_timerList, AlgTool::name(), std::vector< _Tp, _Alloc >::push_back(), std::vector< _Tp, _Alloc >::size(), and std::basic_string< _CharT, _Traits, _Alloc >::substr().

    00038                                          {
    00039     std::string myName;
    00040     if ( 0 < m_indent ) {
    00041       std::string prefix( m_indent, ' ' );
    00042       myName += prefix;
    00043     }
    00044     unsigned int headerSize = 30;
    00045
    00046     std::string space( headerSize, ' ' );
    00047     myName += name + space ;
    00048     myName = myName.substr( 0, headerSize );
    00049
    00050     m_timerList.push_back( TimerForSequencer(myName, m_normFactor) );
    00051     return m_timerList.size() -1;
    00052   };

virtual void SequencerTimerTool::increaseIndent | ( |  | ) | `[inline, virtual]`

Increase the indentation of the name.

Implements ISequencerTimerTool.

Definition at line 55 of file SequencerTimerTool.h.

References m_indent.

    00055 { m_indent += 2; };

virtual void SequencerTimerTool::decreaseIndent | ( |  | ) | `[inline, virtual]`

Decrease the indentation fo the name.

Implements ISequencerTimerTool.

Definition at line 58 of file SequencerTimerTool.h.

References m_indent.

    00058                                    {
    00059     m_indent -= 2;
    00060     if ( 0 > m_indent ) m_indent = 0;
    00061   };

void SequencerTimerTool::start | ( | int | index | ) | `[inline, virtual]`

start the counter, i.e.

register the current time

Implements ISequencerTimerTool.

Definition at line 64 of file SequencerTimerTool.h.

References m_timerList.

    00064 {   m_timerList[index].start();  };

double SequencerTimerTool::stop | ( | int | index | ) | `[inline, virtual]`

stop the counter, return the elapsed time

Implements ISequencerTimerTool.

Definition at line 67 of file SequencerTimerTool.h.

References m_timerList.

    00067 {   return m_timerList[index].stop();  };

double SequencerTimerTool::lastTime | ( | int | index | ) | `[inline, virtual]`

returns the last time

Implements ISequencerTimerTool.

Definition at line 70 of file SequencerTimerTool.h.

References m_timerList.

    00070 {   return m_timerList[index].lastTime();  };

std::string SequencerTimerTool::name | ( | int | index | ) | `[inline, virtual]`

returns the name of the counter

Implements ISequencerTimerTool.

Definition at line 73 of file SequencerTimerTool.h.

References m_timerList.

    00073 {   return m_timerList[index].name();  };

int SequencerTimerTool::indexByName | ( | std::string | name | ) | `[virtual]`

returns the index of the counter with that name, or -1

Implements ISequencerTimerTool.

Definition at line 98 of file SequencerTimerTool.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::find_first_not_of(), std::basic_string< _CharT, _Traits, _Alloc >::find_last_not_of(), m_timerList, AlgTool::name(), std::vector< _Tp, _Alloc >::size(), and std::basic_string< _CharT, _Traits, _Alloc >::substr().

    00098                                                      {
    00099   std::string::size_type beg = name.find_first_not_of(" \t");
    00100   std::string::size_type end = name.find_last_not_of(" \t");
    00101   std::string temp = name.substr( beg, end-beg+1 );
    00102   for ( unsigned int kk=0 ; m_timerList.size() > kk ; kk++ ) {
    00103     beg =  m_timerList[kk].name().find_first_not_of(" \t");
    00104     end =  m_timerList[kk].name().find_last_not_of(" \t");
    00105     if ( m_timerList[kk].name().substr(beg,end-beg+1) == temp ) return kk;
    00106   }
    00107   return -1;
    00108 }

virtual bool SequencerTimerTool::globalTiming | ( |  | ) | `[inline, virtual]`

returns the flag telling that global timing is wanted

Implements ISequencerTimerTool.

Definition at line 79 of file SequencerTimerTool.h.

    00079 { return m_globalTiming; };

## Member Data Documentation

int SequencerTimerTool::m_shots`[private]`

Number of shots for CPU normalisation.

Definition at line 79 of file SequencerTimerTool.h.

Referenced by initialize().

bool SequencerTimerTool::m_normalised`[private]`

Is the time scaled to a nominal PIII ?

Definition at line 85 of file SequencerTimerTool.h.

Referenced by finalize(), and initialize().

int SequencerTimerTool::m_indent`[private]`

Amount of indentation.

Definition at line 86 of file SequencerTimerTool.h.

Referenced by addTimer(), decreaseIndent(), and increaseIndent().

std::vector<TimerForSequencer> SequencerTimerTool::m_timerList`[private]`

Definition at line 87 of file SequencerTimerTool.h.

Referenced by addTimer(), finalize(), indexByName(), lastTime(), name(), start(), and stop().

double SequencerTimerTool::m_normFactor`[private]`

Factor to convert to standard CPU (1 GHz PIII).

Definition at line 88 of file SequencerTimerTool.h.

Referenced by addTimer(), and initialize().

double SequencerTimerTool::m_speedRatio`[private]`

Definition at line 89 of file SequencerTimerTool.h.

Referenced by finalize(), and initialize().

bool SequencerTimerTool::m_globalTiming`[private]`

Definition at line 90 of file SequencerTimerTool.h.

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

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