| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# TimingAuditor Class Reference

Inheritance diagram for TimingAuditor:

[legend]
Collaboration diagram for TimingAuditor:

[legend]

List of all members.

## Detailed Description

Simple auditor which uses SequencerTimerTool for *ALL* algoritms, inclusing the algorithm from main Gaudi "TopAlg" list and algorithms managed by Data-On-Demand Service.

Author:
  Vanya BELYAEV ibelyaev@physics.syr.edu

Date:
  2007-01-31

Definition at line 29 of file TimingAuditor.cpp.

## Public Member Functions
virtual void | before (StandardEventType evt, INamedInterface *alg)
| The following methods are meant to be implemented by the child class...
virtual void | after (StandardEventType evt, INamedInterface *alg, const StatusCode &sc)
| Audit the end of a standard "event".
virtual void | before (CustomEventTypeRef evt, const std::string &name)
| Audit the start of a custom "event" for callers that do not implement INamedInterface.
virtual void | after (CustomEventTypeRef evt, const std::string &name, const StatusCode &sc)
| Audit the end of a custom "event" for callers that do not implement INamedInterface.
virtual void | handle (const Incident &)
| Inform that a new incident has occured.
virtual StatusCode | initialize ()
virtual StatusCode | finalize ()
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface)
| Query interfaces of Interface.
| TimingAuditor (const std::string &name, ISvcLocator *pSvc)
| standard constructor
virtual | ~TimingAuditor ()
| virtual destructor
## Private Types
typedef GaudiUtils::VectorMap < const INamedInterface *, int > | Map
typedef GaudiUtils::HashMap < std::string, int > | MapUser
## Private Member Functions
void | i_beforeInitialize (INamedInterface *alg)
void | i_afterInitialize (INamedInterface *alg)
void | i_beforeExecute (INamedInterface *alg)
void | i_afterExecute (INamedInterface *alg)
| TimingAuditor ()
| TimingAuditor (const TimingAuditor &)
TimingAuditor & | operator= (const TimingAuditor &)
## Private Attributes
IToolSvc * | m_toolSvc
| tool service
IIncidentSvc * | m_incSvc
| incident service
ISequencerTimerTool * | m_timer
| the timer tool
INamedInterface * | m_appMgr
| ApplicationManager.
Map | m_map
int | m_indent
| indentation level
bool | m_inEvent
| "In event" flag
bool | m_goodForDOD
| "optimized for DOD"
MapUser | m_mapUser
| map used to record user timing events

## Member Typedef Documentation

typedef GaudiUtils::VectorMap<const INamedInterface*,int> TimingAuditor::Map`[private]`

Definition at line 97 of file TimingAuditor.cpp.

typedef GaudiUtils::HashMap<std::string,int> TimingAuditor::MapUser`[private]`

Definition at line 106 of file TimingAuditor.cpp.

## Constructor & Destructor Documentation

TimingAuditor::TimingAuditor | ( | const std::string & | name,
|  | ISvcLocator * | pSvc |
| ) |  |  | `[inline]`

standard constructor

Definition at line 59 of file TimingAuditor.cpp.

    00061     : Auditor ( name , pSvc )
    00062     //
    00063     , m_toolSvc    ( 0 )
    00064     , m_incSvc     ( 0 )
    00065     //
    00066     , m_timer      ( 0 )
    00067     //
    00068     , m_appMgr     ( 0 )
    00069     //
    00070     , m_map        (       )
    00071     , m_indent     ( 0     )
    00072     , m_inEvent    ( false )
    00073     , m_goodForDOD ( false )
    00074     , m_mapUser    (       )
    00075   {
    00076     declareProperty ( "OptimizedForDOD" , m_goodForDOD ) ;
    00077   } ;

virtual TimingAuditor::~TimingAuditor | ( |  | ) | `[inline, virtual]`

virtual destructor

Definition at line 79 of file TimingAuditor.cpp.

    00079 {}

TimingAuditor::TimingAuditor | ( |  | ) | `[private]`

TimingAuditor::TimingAuditor | ( | const TimingAuditor & |  | ) | `[private]`

## Member Function Documentation

void TimingAuditor::before | ( | StandardEventType | evt,
|  | INamedInterface * | obj |
| ) |  |  | `[virtual]`

The following methods are meant to be implemented by the child class...

Reimplemented from Auditor.

Definition at line 215 of file TimingAuditor.cpp.

    00216 {
    00217   switch (evt) {
    00218   case IAuditor::Initialize : i_beforeInitialize( alg ); break;
    00219   case IAuditor::Execute    : i_beforeExecute( alg );    break;
    00220   default: break;
    00221   }
    00222 }

void TimingAuditor::after | ( | StandardEventType | ,
|  | INamedInterface * | ,
|  | const StatusCode & | sc |
| ) |  |  | `[virtual]`

Audit the end of a standard "event".

Reimplemented from Auditor.

Definition at line 224 of file TimingAuditor.cpp.

    00225 {
    00226   switch (evt) {
    00227   case IAuditor::Initialize : i_afterInitialize( alg ); break;
    00228   case IAuditor::Execute    : i_afterExecute( alg ); break;
    00229   default: break;
    00230   }
    00231 }

void TimingAuditor::before | ( | CustomEventTypeRef | ,
|  | const std::string & |  |
| ) |  |  | `[virtual]`

Audit the start of a custom "event" for callers that do not implement INamedInterface.

Reimplemented from Auditor.

Definition at line 298 of file TimingAuditor.cpp.

    00299 {
    00300   // Ignore obvious mistakes
    00301   if ( name.empty() && evt.empty() ) { return; }
    00302
    00303   // look for the user timer in the map
    00304   int timer = 0;
    00305   std::string nick = name + ":" + evt;
    00306   MapUser::iterator found = m_mapUser.find( nick );
    00307
    00308   if ( m_mapUser.end() == found ) {
    00309     // add a new timer if not yet available
    00310     timer = m_timer->addTimer( nick ) ;
    00311     m_mapUser[nick] = timer;
    00312   }
    00313   else {
    00314     timer = found->second;
    00315   }
    00316
    00317   m_timer->start( timer );
    00318 }

void TimingAuditor::after | ( | CustomEventTypeRef | ,
|  | const std::string & | ,
|  | const StatusCode & | sc |
| ) |  |  | `[virtual]`

Audit the end of a custom "event" for callers that do not implement INamedInterface.

Reimplemented from Auditor.

Definition at line 320 of file TimingAuditor.cpp.

    00321 {
    00322   // Ignore obvious mistakes
    00323   if ( name.empty() && evt.empty() ) { return; }
    00324
    00325   // look for the user timer in the map
    00326   std::string nick = name + ":" + evt;
    00327   MapUser::iterator found = m_mapUser.find( nick );
    00328
    00329   // We cannot do much if the timer is not available
    00330   if ( m_mapUser.end() == found ) {
    00331     MsgStream log(msgSvc(), this->name());
    00332     log << MSG::WARNING << "Trying to stop the measure  of the timing for '"
    00333                         << nick << "' but it was never started. Check the code"
    00334                         << endmsg;
    00335     return;
    00336   }
    00337   m_timer->stop( found->second );
    00338 }

void TimingAuditor::i_beforeInitialize | ( | INamedInterface * | alg | ) | `[private]`

Definition at line 233 of file TimingAuditor.cpp.

    00234 {
    00235   if ( m_goodForDOD ) { return ; }
    00236   //
    00237   if ( 0 == alg ) { return ; }
    00238   Map::iterator found = m_map.find( alg ) ;
    00239   if ( m_map.end() != found ) { return ; }
    00240   ++m_indent ;
    00241   std::string nick = alg->name() ;
    00242   if ( 0 < m_indent ) { nick = std::string ( m_indent , ' ') + nick ; }
    00243   if ( m_inEvent )
    00244   {
    00245     nick[0] = '*' ;
    00246     MsgStream log( msgSvc() , name() ) ;
    00247     log << MSG::DEBUG
    00248         << "Insert non-structural component '"
    00249         << alg->name() << "' of type '"
    00250         << System::typeinfoName(typeid(*alg)) << "' at level "
    00251         << m_indent << endreq ;
    00252   }
    00253   int timer = m_timer->addTimer( nick ) ;
    00254   m_map.insert ( alg , timer ) ;
    00255   m_timer->start( timer ) ;
    00256 }

void TimingAuditor::i_afterInitialize | ( | INamedInterface * | alg | ) | `[private]`

Definition at line 258 of file TimingAuditor.cpp.

    00259 {
    00260   if ( m_goodForDOD ) { return ; }
    00261   if ( 0 == alg     ) { return ; }
    00262   --m_indent ;
    00263 }

void TimingAuditor::i_beforeExecute | ( | INamedInterface * | alg | ) | `[private]`

Definition at line 265 of file TimingAuditor.cpp.

    00266 {
    00267   if ( 0 == alg ) { return ; }
    00268   ++m_indent ;
    00269   Map::iterator found = m_map.find( alg ) ;
    00270   if ( m_map.end() == found )
    00271   {
    00272     MsgStream log( msgSvc() , name() ) ;
    00273     log << MSG::DEBUG
    00274         << "Insert non-structural component '"
    00275         << alg->name() << "' of type '"
    00276         << System::typeinfoName(typeid(*alg)) << "' at level "
    00277         << m_indent << endreq ;
    00278     std::string nick = alg->name() ;
    00279     if ( 0 < m_indent  ) { nick = std::string ( m_indent , ' ') + nick ; }
    00280     if ( !m_goodForDOD ) { nick[0]='*' ;}
    00281     int timer = m_timer->addTimer( nick ) ;
    00282     m_map.insert ( alg , timer ) ;
    00283     m_timer->start( timer ) ;
    00284     return ;
    00285   }
    00286   m_timer->start( found->second ) ;
    00287 }

void TimingAuditor::i_afterExecute | ( | INamedInterface * | alg | ) | `[private]`

Definition at line 289 of file TimingAuditor.cpp.

    00290 {
    00291   if ( 0 == alg ) { return ; }
    00292   Map::iterator found = m_map.find( alg ) ;
    00293   if ( m_map.end() == found ) { return ; }
    00294   m_timer->stop( found->second ) ;
    00295   --m_indent ;
    00296 }

void TimingAuditor::handle | ( | const Incident & | i | ) | `[virtual]`

Inform that a new incident has occured.

Implements IIncidentListener.

Definition at line 340 of file TimingAuditor.cpp.

    00341 {
    00342   if      ( IncidentType::BeginEvent == i.type () )
    00343   {
    00344     m_timer -> start ( m_map[ m_appMgr ] ) ;
    00345     ++m_indent ;
    00346     m_inEvent = true ;
    00347   }
    00348   else if ( IncidentType::EndEvent   == i.type () )
    00349   {
    00350     m_timer -> stop  ( m_map[ m_appMgr ] ) ;
    00351     --m_indent ;
    00352     m_inEvent = false ;
    00353   }
    00354 }

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

Reimplemented from Auditor.

Definition at line 128 of file TimingAuditor.cpp.

    00129 {
    00130   StatusCode sc = Auditor::initialize() ;
    00131   if ( sc.isFailure() ) { return sc ; }                  // RETURN
    00132
    00133   MsgStream log ( msgSvc() , name() ) ;
    00134
    00135   // get tool service
    00136   if ( 0 == m_toolSvc )
    00137   {
    00138     StatusCode sc = Auditor::service ( "ToolSvc" , m_toolSvc ) ;
    00139     if ( sc.isFailure() )
    00140     {
    00141       log << "Could not retrieve 'ToolSvc' " << sc << endreq ;
    00142       return sc ;                                        // RETURN
    00143     }
    00144     if ( 0 == m_timer )
    00145     {
    00146       sc = m_toolSvc->retrieveTool
    00147         ( "SequencerTimerTool/TIMER" , m_timer , this  , true ) ;
    00148       if ( sc.isFailure() )
    00149       {
    00150         log << MSG::ERROR
    00151             << "Could not retrieve ISequencerTimerTool" << endreq ;
    00152         return sc ;
    00153       }
    00154     }
    00155   }
    00156   // get incident service
    00157   if ( 0 == m_incSvc )
    00158   {
    00159     StatusCode sc = Auditor::service ( "IncidentSvc" , m_incSvc ) ;
    00160     if ( sc.isFailure() )
    00161     {
    00162       log << MSG::ERROR
    00163           << "Could not retrieve 'IncidentSvc'" << sc << endreq ;
    00164       return sc ;
    00165     }
    00166     m_incSvc -> addListener ( this , IncidentType::BeginEvent ) ;
    00167     m_incSvc -> addListener ( this , IncidentType::EndEvent   ) ;
    00168   }
    00169   // get the application manager
    00170   if ( 0 == m_appMgr )
    00171   {
    00172     StatusCode sc = Auditor::service ( "ApplicationMgr" , m_appMgr ) ;
    00173     if ( sc.isFailure() )
    00174     {
    00175       log << MSG::ERROR
    00176           << "Could not retrieve 'ApplicationMgr'" << sc << endreq ;
    00177       return sc ;
    00178     }
    00179     if ( m_map.end() == m_map.find( m_appMgr ) )
    00180     {
    00181       int timer = m_timer->addTimer( "EVENT LOOP" ) ;
    00182       m_map.insert ( m_appMgr , timer ) ;
    00183     }
    00184   }
    00185   //
    00186   return StatusCode::SUCCESS ;
    00187 }

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

Reimplemented from Auditor.

Definition at line 189 of file TimingAuditor.cpp.

    00190 {
    00191   if ( 0 != m_incSvc )
    00192   {
    00193     m_incSvc -> removeListener ( this , IncidentType::BeginEvent ) ;
    00194     m_incSvc -> removeListener ( this , IncidentType::EndEvent   ) ;
    00195     m_incSvc -> release () ;
    00196     m_incSvc = 0 ;
    00197   }
    00198   if ( 0 != m_toolSvc )
    00199   {
    00200     // the 2 following line are commented out: it is
    00201     // is a temporary hack which prevent a crash due to a problem in
    00202     // the reference counting
    00203     //     if ( 0 != m_timer )
    00204     //     { m_toolSvc -> releaseTool ( m_timer ) . ignore() ; m_timer = 0 ; }
    00205     m_toolSvc -> release () ;
    00206     m_toolSvc = 0 ;
    00207   }
    00208   if ( 0 != m_appMgr ) { m_appMgr -> release () ;  m_appMgr = 0 ; }
    00209   // clear the map
    00210   m_map.clear() ;
    00211   // finalize the base class
    00212   return Auditor::finalize () ;
    00213 }

StatusCode TimingAuditor::queryInterface | ( | const InterfaceID & | riid,
|  | void ** | ppvInterface |
| ) |  |  | `[virtual]`

Query interfaces of Interface.

Parameters:

  | riid | ID of Interface to be retrieved
  | ppvInterface | Pointer to Location for interface pointer

Reimplemented from Auditor.

Definition at line 116 of file TimingAuditor.cpp.

    00118 {
    00119   if      ( 0 == ppv ) { return StatusCode::FAILURE ; }  // RETURN
    00120   else if ( IIncidentListener::interfaceID() == riid )
    00121   { *ppv = static_cast<IIncidentListener*> ( this ) ; }
    00122   else
    00123   { return Auditor::queryInterface( riid , ppv ) ; } // RETURN
    00124   addRef() ;
    00125   return StatusCode::SUCCESS ;
    00126 } ;

TimingAuditor& TimingAuditor::operator= | ( | const TimingAuditor & |  | ) | `[private]`

## Member Data Documentation

IToolSvc* TimingAuditor::m_toolSvc`[private]`

tool service

Definition at line 89 of file TimingAuditor.cpp.

IIncidentSvc* TimingAuditor::m_incSvc`[private]`

incident service

Definition at line 91 of file TimingAuditor.cpp.

ISequencerTimerTool* TimingAuditor::m_timer`[private]`

the timer tool

Definition at line 93 of file TimingAuditor.cpp.

INamedInterface* TimingAuditor::m_appMgr`[private]`

ApplicationManager.

Definition at line 95 of file TimingAuditor.cpp.

Map TimingAuditor::m_map`[private]`

Definition at line 98 of file TimingAuditor.cpp.

int TimingAuditor::m_indent`[private]`

indentation level

Definition at line 100 of file TimingAuditor.cpp.

bool TimingAuditor::m_inEvent`[private]`

"In event" flag

Definition at line 102 of file TimingAuditor.cpp.

bool TimingAuditor::m_goodForDOD`[private]`

"optimized for DOD"

Definition at line 104 of file TimingAuditor.cpp.

MapUser TimingAuditor::m_mapUser`[private]`

map used to record user timing events

Definition at line 107 of file TimingAuditor.cpp.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r4/GaudiAlg/src/components/TimingAuditor.cpp