| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# SequencerTimerTool Class Reference

Implements the time measurement inside a sequencer. More...

`#include <SequencerTimerTool.h>`

Inheritance diagram for SequencerTimerTool:
[legend]
Collaboration diagram for SequencerTimerTool:
[legend]

List of all members.

## 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
std::string::size_type | m_headerSize
| Size of the name field.

## Detailed Description

Implements the time measurement inside a sequencer.

The width of the timing table column printing the algorithm name is 30 by default. That can be changed via

    TimingAuditor().addTool(SequencerTimerTool("TIMER"))
    TimingAuditor().TIMER.ColumnWidth = 50

Author:
  Olivier Callot

Date:
  2004-05-19

Definition at line 27 of file SequencerTimerTool.h.

## 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   declareProperty( "NameSize"     , m_headerSize = 30, "Number of characters to be used in algorithm name column" );
    00038 }

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

Destructor.

Definition at line 42 of file SequencerTimerTool.cpp.

    00042 {}

## Member Function Documentation

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

initialize method, to compute the normalisation factor

Reimplemented from GaudiTool.

Definition at line 48 of file SequencerTimerTool.cpp.

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

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

finalize method, to print the time summary table

Reimplemented from GaudiTool.

Definition at line 74 of file SequencerTimerTool.cpp.

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

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

add a timer entry with the specified name

Implements ISequencerTimerTool.

Definition at line 44 of file SequencerTimerTool.h.

    00044                                          {
    00045     std::string myName;
    00046     if ( 0 < m_indent ) {
    00047       std::string prefix( m_indent, ' ' );
    00048       myName += prefix;
    00049     }
    00050     std::string space( m_headerSize, ' ' );
    00051     myName += name + space ;
    00052     myName = myName.substr( 0, m_headerSize );
    00053
    00054     m_timerList.push_back( TimerForSequencer(myName, m_normFactor) );
    00055     return m_timerList.size() -1;
    00056   };

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

Increase the indentation of the name.

Implements ISequencerTimerTool.

Definition at line 59 of file SequencerTimerTool.h.

    00059 { m_indent += 2; };

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

Decrease the indentation fo the name.

Implements ISequencerTimerTool.

Definition at line 62 of file SequencerTimerTool.h.

    00062                                    {
    00063     m_indent -= 2;
    00064     if ( 0 > m_indent ) m_indent = 0;
    00065   };

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

start the counter, i.e.

register the current time

Implements ISequencerTimerTool.

Definition at line 68 of file SequencerTimerTool.h.

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

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

stop the counter, return the elapsed time

Implements ISequencerTimerTool.

Definition at line 71 of file SequencerTimerTool.h.

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

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

returns the last time

Implements ISequencerTimerTool.

Definition at line 74 of file SequencerTimerTool.h.

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

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

returns the name of the counter

Implements ISequencerTimerTool.

Definition at line 77 of file SequencerTimerTool.h.

    00077 {   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 99 of file SequencerTimerTool.cpp.

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

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

returns the flag telling that global timing is wanted

Implements ISequencerTimerTool.

Definition at line 83 of file SequencerTimerTool.h.

    00083 { return m_globalTiming; };

## Member Data Documentation

int SequencerTimerTool::m_shots`[private]`

Number of shots for CPU normalisation.

Definition at line 83 of file SequencerTimerTool.h.

bool SequencerTimerTool::m_normalised`[private]`

Is the time scaled to a nominal PIII ?

Definition at line 89 of file SequencerTimerTool.h.

int SequencerTimerTool::m_indent`[private]`

Amount of indentation.

Definition at line 90 of file SequencerTimerTool.h.

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

Definition at line 91 of file SequencerTimerTool.h.

double SequencerTimerTool::m_normFactor`[private]`

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

Definition at line 92 of file SequencerTimerTool.h.

double SequencerTimerTool::m_speedRatio`[private]`

Definition at line 93 of file SequencerTimerTool.h.

bool SequencerTimerTool::m_globalTiming`[private]`

Definition at line 94 of file SequencerTimerTool.h.

std::string::size_type SequencerTimerTool::m_headerSize`[private]`

Size of the name field.

Definition at line 95 of file SequencerTimerTool.h.

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

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