| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Member Functions | Private Attributes

# 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 normalization 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 of 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 normalization.
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, name = "TIMER")
    TimingAuditor().TIMER.NameSize = 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.

      : GaudiTool ( type, name , parent )
      , m_indent( 0 )
      , m_normFactor( 0.001 )
    {
      declareInterface<ISequencerTimerTool>(this);

      m_shots = 3500000 ; // 1s on 2.8GHz Xeon, gcc 3.2, -o2
      declareProperty( "shots"        , m_shots );
      declareProperty( "Normalised"   , m_normalised = false );
      declareProperty( "GlobalTiming" , m_globalTiming = false );
      declareProperty( "NameSize"     , m_headerSize = 30, "Number of characters to be used in algorithm name column" );
    }

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

Destructor.

Definition at line 42 of file SequencerTimerTool.cpp.

    {}

## Member Function Documentation

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.

                                             {
        std::string myName;
        if ( 0 < m_indent ) {
          std::string prefix( m_indent, ' ' );
          myName += prefix;
        }
        std::string space( m_headerSize, ' ' );
        myName += name + space ;
        myName = myName.substr( 0, m_headerSize );

        m_timerList.push_back( TimerForSequencer(myName, m_normFactor) );
        return m_timerList.size() -1;
      };

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

Decrease the indentation of the name.

Implements ISequencerTimerTool.

Definition at line 62 of file SequencerTimerTool.h.

                                       {
        m_indent -= 2;
        if ( 0 > m_indent ) m_indent = 0;
      };

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

finalize method, to print the time summary table

Reimplemented from GaudiTool.

Definition at line 74 of file SequencerTimerTool.cpp.

                                              {

      std::string line(m_headerSize + 68, '-');
      info() << line << endmsg
             << "This machine has a speed about "
             << format( "%6.2f", 1000.*m_speedRatio)
             << " times the speed of a 2.8 GHz Xeon.";
      if ( m_normalised ) info() <<" *** All times are renormalized ***";
      info() << endmsg << TimerForSequencer::header( m_headerSize ) << endmsg
             << line << endmsg;

      std::string lastName = "";
      for ( unsigned int kk=0 ; m_timerList.size() > kk ; kk++ ) {
        if ( lastName == m_timerList[kk].name() ) continue; // suppress duplicate
        lastName = m_timerList[kk].name();
        info() << m_timerList[kk] << endmsg;
      }
      info() << line << endmsg;

      return GaudiTool::finalize();
    }

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

returns the flag telling that global timing is wanted

Implements ISequencerTimerTool.

Definition at line 86 of file SequencerTimerTool.h.

    { return m_globalTiming; };

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

Increase the indentation of the name.

Implements ISequencerTimerTool.

Definition at line 59 of file SequencerTimerTool.h.

    { m_indent += 2; };

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.

                                                         {
      std::string::size_type beg = name.find_first_not_of(" \t");
      std::string::size_type end = name.find_last_not_of(" \t");
      std::string temp = name.substr( beg, end-beg+1 );
      for ( unsigned int kk=0 ; m_timerList.size() > kk ; kk++ ) {
        beg =  m_timerList[kk].name().find_first_not_of(" \t");
        end =  m_timerList[kk].name().find_last_not_of(" \t");
        if ( m_timerList[kk].name().substr(beg,end-beg+1) == temp ) return kk;
      }
      return -1;
    }

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

initialize method, to compute the normalization factor

Reimplemented from GaudiTool.

Definition at line 48 of file SequencerTimerTool.cpp.

                                                {
      GaudiTool::initialize();
      double sum = 0;
      TimerForSequencer norm( "normalize", m_normFactor );
      norm.start();
      IRndmGenSvc* rsvc = svc<IRndmGenSvc>( "RndmGenSvc", true );
      { // Use dummy loop suggested by Vanya Belyaev:
        Rndm::Numbers gauss;
        gauss.initialize( rsvc , Rndm::Gauss(0.,1.0) ).ignore();
        unsigned int shots = m_shots;
        while( 0 < --shots ) { sum += gauss() * sum ; }
      }
      norm.stop();
      double time = norm.lastCpu();
      m_speedRatio = 1./time;
      info() << "This machine has a speed about "
             << format( "%6.2f", 1000.*m_speedRatio)
             << " times the speed of a 2.8 GHz Xeon." << endmsg ;
       if ( m_normalised ) {
        m_normFactor = m_speedRatio;
      }
      return StatusCode::SUCCESS;
    }

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

returns the last time

Implements ISequencerTimerTool.

Definition at line 76 of file SequencerTimerTool.h.

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

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

returns the name of the counter

Implements ISequencerTimerTool.

Definition at line 80 of file SequencerTimerTool.h.

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

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

start the counter, i.e.

register the current time

Implements ISequencerTimerTool.

Definition at line 69 of file SequencerTimerTool.h.

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

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

stop the counter, return the elapsed time

Implements ISequencerTimerTool.

Definition at line 73 of file SequencerTimerTool.h.

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

## Member Data Documentation

bool SequencerTimerTool::m_globalTiming`[private]`

Definition at line 97 of file SequencerTimerTool.h.

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

Size of the name field.

Definition at line 98 of file SequencerTimerTool.h.

int SequencerTimerTool::m_indent`[private]`

Amount of indentation.

Definition at line 93 of file SequencerTimerTool.h.

bool SequencerTimerTool::m_normalised`[private]`

Is the time scaled to a nominal PIII ?

Definition at line 92 of file SequencerTimerTool.h.

double SequencerTimerTool::m_normFactor`[private]`

Factor to convert to standard CPU (1 GHz PIII)

Definition at line 95 of file SequencerTimerTool.h.

int SequencerTimerTool::m_shots`[private]`

Number of shots for CPU normalization.

Definition at line 86 of file SequencerTimerTool.h.

double SequencerTimerTool::m_speedRatio`[private]`

Definition at line 96 of file SequencerTimerTool.h.

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

Definition at line 94 of file SequencerTimerTool.h.

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

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

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