| # Gaudi Framework, version v23r0 |

Home |  | Generated: Mon Jan 30 2012

Public Member Functions | Private Types | Private Member Functions | Private Attributes

# TimingAuditor Class Reference

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

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

List of all members.

## 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)
virtual void | before (CustomEventTypeRef evt, const std::string &name)
virtual void | after (CustomEventTypeRef evt, const std::string &name, const StatusCode &sc)
virtual void | handle (const Incident &)
| Inform that a new incident has occurred.
virtual StatusCode | initialize ()
| factory:
virtual StatusCode | finalize ()
| 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

## Detailed Description

Simple auditor which uses SequencerTimerTool for *ALL* algorithms, including 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 33 of file TimingAuditor.cpp.

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

        : base_class ( name , pSvc )
        //
        , m_toolSvc    ( 0 )
        , m_incSvc     ( 0 )
        //
        , m_timer      ( 0 )
        //
        , m_appMgr     ( 0 )
        //
        , m_map        (       )
        , m_indent     ( 0     )
        , m_inEvent    ( false )
        , m_goodForDOD ( false )
        , m_mapUser    (       )
      {
        declareProperty ( "OptimizedForDOD" , m_goodForDOD ) ;
      } ;

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

virtual destructor

Definition at line 79 of file TimingAuditor.cpp.

    {}

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

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

## Member Function Documentation

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

Reimplemented from Auditor.

Definition at line 211 of file TimingAuditor.cpp.

    {
      switch (evt) {
      case IAuditor::Initialize : i_afterInitialize( alg ); break;
      case IAuditor::Execute    : i_afterExecute( alg ); break;
      default: break;
      }
    }

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

Reimplemented from Auditor.

Definition at line 307 of file TimingAuditor.cpp.

    {
      // Ignore obvious mistakes
      if ( name.empty() && evt.empty() ) { return; }

      // look for the user timer in the map
      std::string nick = name + ":" + evt;
      MapUser::iterator found = m_mapUser.find( nick );

      // We cannot do much if the timer is not available
      if ( m_mapUser.end() == found ) {
        MsgStream log(msgSvc(), this->name());
        log << MSG::WARNING << "Trying to stop the measure  of the timing for '"
                            << nick << "' but it was never started. Check the code"
                            << endmsg;
        return;
      }
      m_timer->stop( found->second );
    }

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 202 of file TimingAuditor.cpp.

    {
      switch (evt) {
      case IAuditor::Initialize : i_beforeInitialize( alg ); break;
      case IAuditor::Execute    : i_beforeExecute( alg );    break;
      default: break;
      }
    }

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

Reimplemented from Auditor.

Definition at line 285 of file TimingAuditor.cpp.

    {
      // Ignore obvious mistakes
      if ( name.empty() && evt.empty() ) { return; }

      // look for the user timer in the map
      int timer = 0;
      std::string nick = name + ":" + evt;
      MapUser::iterator found = m_mapUser.find( nick );

      if ( m_mapUser.end() == found ) {
        // add a new timer if not yet available
        timer = m_timer->addTimer( nick ) ;
        m_mapUser[nick] = timer;
      }
      else {
        timer = found->second;
      }

      m_timer->start( timer );
    }

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

Reimplemented from Auditor.

Definition at line 176 of file TimingAuditor.cpp.

    {
      if ( 0 != m_incSvc )
      {
        m_incSvc -> removeListener ( this , IncidentType::BeginEvent ) ;
        m_incSvc -> removeListener ( this , IncidentType::EndEvent   ) ;
        m_incSvc -> release () ;
        m_incSvc = 0 ;
      }
      if ( 0 != m_toolSvc )
      {
        // the 2 following line are commented out: it is
        // is a temporary hack which prevent a crash due to a problem in
        // the reference counting
        //     if ( 0 != m_timer )
        //     { m_toolSvc -> releaseTool ( m_timer ) . ignore() ; m_timer = 0 ; }
        m_toolSvc -> release () ;
        m_toolSvc = 0 ;
      }
      if ( 0 != m_appMgr ) { m_appMgr -> release () ;  m_appMgr = 0 ; }
      // clear the map
      m_map.clear() ;
      // finalize the base class
      return Auditor::finalize () ;
    }

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

Inform that a new incident has occurred.

Implements IIncidentListener.

Definition at line 327 of file TimingAuditor.cpp.

    {
      if      ( IncidentType::BeginEvent == i.type () )
      {
        m_timer -> start ( m_map[ m_appMgr ] ) ;
        ++m_indent ;
        m_inEvent = true ;
      }
      else if ( IncidentType::EndEvent   == i.type () )
      {
        m_timer -> stop  ( m_map[ m_appMgr ] ) ;
        --m_indent ;
        m_inEvent = false ;
      }
    }

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

Definition at line 276 of file TimingAuditor.cpp.

    {
      if ( 0 == alg ) { return ; }
      Map::iterator found = m_map.find( alg ) ;
      if ( m_map.end() == found ) { return ; }
      m_timer->stop( found->second ) ;
      --m_indent ;
    }

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

Definition at line 245 of file TimingAuditor.cpp.

    {
      if ( m_goodForDOD ) { return ; }
      if ( 0 == alg     ) { return ; }
      --m_indent ;
    }

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

Definition at line 252 of file TimingAuditor.cpp.

    {
      if ( 0 == alg ) { return ; }
      ++m_indent ;
      Map::iterator found = m_map.find( alg ) ;
      if ( m_map.end() == found )
      {
        MsgStream log( msgSvc() , name() ) ;
        log << MSG::DEBUG
            << "Insert non-structural component '"
            << alg->name() << "' of type '"
            << System::typeinfoName(typeid(*alg)) << "' at level "
            << m_indent << endmsg ;
        std::string nick = alg->name() ;
        if ( 0 < m_indent  ) { nick = std::string ( m_indent , ' ') + nick ; }
        if ( !m_goodForDOD ) { nick[0]='*' ;}
        int timer = m_timer->addTimer( nick ) ;
        m_map.insert ( alg , timer ) ;
        m_timer->start( timer ) ;
        return ;
      }
      m_timer->start( found->second ) ;
    }

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

Definition at line 220 of file TimingAuditor.cpp.

    {
      if ( m_goodForDOD ) { return ; }
      //
      if ( 0 == alg ) { return ; }
      Map::iterator found = m_map.find( alg ) ;
      if ( m_map.end() != found ) { return ; }
      ++m_indent ;
      std::string nick = alg->name() ;
      if ( 0 < m_indent ) { nick = std::string ( m_indent , ' ') + nick ; }
      if ( m_inEvent )
      {
        nick[0] = '*' ;
        MsgStream log( msgSvc() , name() ) ;
        log << MSG::DEBUG
            << "Insert non-structural component '"
            << alg->name() << "' of type '"
            << System::typeinfoName(typeid(*alg)) << "' at level "
            << m_indent << endmsg ;
      }
      int timer = m_timer->addTimer( nick ) ;
      m_map.insert ( alg , timer ) ;
      m_timer->start( timer ) ;
    }

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

factory:

Reimplemented from Auditor.

Definition at line 115 of file TimingAuditor.cpp.

    {
      StatusCode sc = Auditor::initialize() ;
      if ( sc.isFailure() ) { return sc ; }                  // RETURN

      MsgStream log ( msgSvc() , name() ) ;

      // get tool service
      if ( 0 == m_toolSvc )
      {
        sc = Auditor::service ( "ToolSvc" , m_toolSvc ) ;
        if ( sc.isFailure() )
        {
          log << "Could not retrieve 'ToolSvc' " << sc << endmsg ;
          return sc ;                                        // RETURN
        }
        if ( 0 == m_timer )
        {
          sc = m_toolSvc->retrieveTool
            ( "SequencerTimerTool/TIMER" , m_timer , this  , true ) ;
          if ( sc.isFailure() )
          {
            log << MSG::ERROR
                << "Could not retrieve ISequencerTimerTool" << endmsg ;
            return sc ;
          }
        }
      }
      // get incident service
      if ( 0 == m_incSvc )
      {
        sc = Auditor::service ( "IncidentSvc" , m_incSvc ) ;
        if ( sc.isFailure() )
        {
          log << MSG::ERROR
              << "Could not retrieve 'IncidentSvc'" << sc << endmsg ;
          return sc ;
        }
        m_incSvc -> addListener ( this , IncidentType::BeginEvent ) ;
        m_incSvc -> addListener ( this , IncidentType::EndEvent   ) ;
      }
      // get the application manager
      if ( 0 == m_appMgr )
      {
        sc = Auditor::service ( "ApplicationMgr" , m_appMgr ) ;
        if ( sc.isFailure() )
        {
          log << MSG::ERROR
              << "Could not retrieve 'ApplicationMgr'" << sc << endmsg ;
          return sc ;
        }
        if ( m_map.end() == m_map.find( m_appMgr ) )
        {
          int timer = m_timer->addTimer( "EVENT LOOP" ) ;
          m_map.insert ( m_appMgr , timer ) ;
        }
      }
      //
      return StatusCode::SUCCESS ;
    }

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

## Member Data Documentation

INamedInterface* TimingAuditor::m_appMgr`[private]`

ApplicationManager.

Definition at line 95 of file TimingAuditor.cpp.

bool TimingAuditor::m_goodForDOD`[private]`

"optimized for DOD"

Definition at line 104 of file TimingAuditor.cpp.

IIncidentSvc* TimingAuditor::m_incSvc`[private]`

incident service

Definition at line 91 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.

Map TimingAuditor::m_map`[private]`

Definition at line 98 of file TimingAuditor.cpp.

MapUser TimingAuditor::m_mapUser`[private]`

map used to record user timing events

Definition at line 107 of file TimingAuditor.cpp.

ISequencerTimerTool* TimingAuditor::m_timer`[private]`

the timer tool

Definition at line 93 of file TimingAuditor.cpp.

IToolSvc* TimingAuditor::m_toolSvc`[private]`

tool service

Definition at line 89 of file TimingAuditor.cpp.

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

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

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