| # Gaudi Framework, version v23r1 |

Home |  | Generated: Wed Feb 29 2012

Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes

# Google::AuditorBase Class Reference

Base for Google Auditors. More...

`#include <GoogleAuditor.cpp>`

Inheritance diagram for Google::AuditorBase:
[legend]
Collaboration diagram for Google::AuditorBase:
[legend]

List of all members.

## Public Member Functions
| AuditorBase (const std::string &name, ISvcLocator *pSvcLocator)
| Constructor.
virtual | ~AuditorBase ()
| Destructor.
StatusCode | initialize ()
| Initialize the auditor base.
StatusCode | finalize ()
| Finalize the auditor base.
void | handle (const Incident &incident)
| Implement the handle method for the Incident service.
void | before (StandardEventType type, INamedInterface *i)
| The following methods are meant to be implemented by the child class...
void | before (CustomEventTypeRef type, INamedInterface *i)
void | before (StandardEventType type, const std::string &s)
void | before (CustomEventTypeRef, const std::string &s)
void | after (StandardEventType type, INamedInterface *i, const StatusCode &sc)
void | after (CustomEventTypeRef type, INamedInterface *i, const StatusCode &sc)
void | after (StandardEventType type, const std::string &s, const StatusCode &sc)
void | after (CustomEventTypeRef, const std::string &s, const StatusCode &)
void | beforeInitialize (INamedInterface *i)
void | beforeReinitialize (INamedInterface *i)
void | beforeExecute (INamedInterface *i)
void | beforeBeginRun (INamedInterface *i)
void | beforeEndRun (INamedInterface *i)
void | beforeFinalize (INamedInterface *i)
void | afterInitialize (INamedInterface *i)
void | afterReinitialize (INamedInterface *i)
void | afterExecute (INamedInterface *i, const StatusCode &s)
void | afterBeginRun (INamedInterface *i)
void | afterEndRun (INamedInterface *i)
void | afterFinalize (INamedInterface *i)
## Protected Member Functions
virtual void | google_before (const std::string &s)=0
| Start the google tool.
virtual void | google_after (const std::string &s)=0
| stop the google tool
virtual bool | alreadyRunning ()=0
| check if we are already running the tool
## Protected Attributes
MsgStream | m_log
| Messaging object.
## Private Member Functions
void | startAudit ()
| Start a full event audit.
void | stopAudit ()
| stop a full event audit
bool | isSequencer (INamedInterface *i) const
| Check if the component in question is a GaudiSequencer or a Sequencer.
## Private Attributes
std::vector< std::string > | m_when
| When to audit the algorithms.
std::vector< std::string > | m_veto
| Veto list. Any component in this list will not be audited.
std::vector< std::string > | m_list
| Any component in this list will be audited. If empty, all will be done.
unsigned long long | m_eventsToSkip
| Number of events to skip before auditing.
bool | m_skipSequencers
| Boolean indicating if sequencers should be skipped or not.
int | m_freq
| The frequency to audit events. -1 means all events.
bool | m_audit
| Internal flag to say if auditing is enabled or not for the current event.
unsigned long long | m_nEvts
| Number of events processed.
bool | m_fullEventAudit
| Flag to indicate if full event auditing is enabled or not.
unsigned long long | m_nSampleEvents
| Number of events to include in a full event audit.
unsigned long long | m_sampleEventCount
| Internal count of the number of events currently processed during an audit.
bool | m_inFullAudit
| Internal flag to indicate if we are current in a full event audit.
std::string | m_startedBy
| Name of the component we are currently auditing.

## Detailed Description

Base for Google Auditors.

Author:
  Chris Jones

Date:
  18/04/2011

Definition at line 35 of file GoogleAuditor.cpp.

## Constructor & Destructor Documentation

Google::AuditorBase::AuditorBase | ( | const std::string & | name,
|  | ISvcLocator * | pSvcLocator
| ) |  |

Constructor.

Definition at line 285 of file GoogleAuditor.cpp.

        : base_class ( name , pSvcLocator )
        , m_log      ( msgSvc() , name )
        , m_audit    ( false )
        , m_nEvts    ( 0 )
        , m_sampleEventCount( 0 )
        , m_inFullAudit ( false )
      {
        declareProperty("ActivateAt", m_when = boost::assign::list_of
                        ("Initialize")
                        ("ReInitialize")
                        ("Execute")
                        ("BeginRun")
                        ("EndRun")
                        ("Finalize"),
                        "List of phases to activate the Auditoring during" );
        declareProperty("DisableFor", m_veto,
                        "List of component names to disable the auditing for" );
        declareProperty("EnableFor", m_list );
        declareProperty("ProfileFreq", m_freq = -1,
                        "The frequence to audit events. -1 means all events" );
        declareProperty("DoFullEventProfile", m_fullEventAudit = false,
                        "If true, instead of individually auditing components, the full event (or events) will be audited in one go" );
        declareProperty("FullEventNSampleEvents", m_nSampleEvents = 1,
                        "The number of events to include in a full event audit, if enabled" );
        declareProperty("SkipEvents", m_eventsToSkip = 0,
                        "Number of events to skip before activating the auditing" );
        declareProperty("SkipSequencers", m_skipSequencers = true,
                        "If true, auditing will be skipped for Sequencer objects." );
      }

virtual Google::AuditorBase::~AuditorBase | ( | ) | `[inline, virtual]`

Destructor.

Definition at line 44 of file GoogleAuditor.cpp.

    {  }

## Member Function Documentation

void Google::AuditorBase::after | ( | StandardEventType | type,
|  | INamedInterface * | i,
|  | const StatusCode & | sc
| ) |  | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 187 of file GoogleAuditor.cpp.

        {
          if ( !m_skipSequencers || !isSequencer(i) )
          {
            std::ostringstream t;
            t << type;
            after(t.str(),i,sc);
          }
        }

void Google::AuditorBase::after | ( | CustomEventTypeRef | type,
|  | INamedInterface * | i,
|  | const StatusCode & | sc
| ) |  | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 197 of file GoogleAuditor.cpp.

        {
          if ( !m_skipSequencers || !isSequencer(i) )
          {
            after(type,i->name(),sc);
          }
        }

void Google::AuditorBase::after | ( | StandardEventType | type,
|  | const std::string & | s,
|  | const StatusCode & | sc
| ) |  | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 205 of file GoogleAuditor.cpp.

        {
          std::ostringstream t;
          t << type;
          after(t.str(),s,sc);
        }

void Google::AuditorBase::after | ( | CustomEventTypeRef | ,
|  | const std::string & | s,
|  | const StatusCode & |
| ) |  | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 212 of file GoogleAuditor.cpp.

        {
          if ( !m_fullEventAudit && m_audit &&
               std::find(m_veto.begin(),m_veto.end(),s) == m_veto.end() &&
               ( m_list.empty() || std::find(m_list.begin(),m_list.end(),s) != m_list.end() ) )
          {
            if ( s == m_startedBy )
            {
              std::ostringstream t;
              t << s << "-Event" << m_nEvts;
              google_after(t.str());
            }
          }
        }

void Google::AuditorBase::afterBeginRun | ( | INamedInterface * | i ) | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 238 of file GoogleAuditor.cpp.

    { return after(IAuditor::BeginRun,i,StatusCode::SUCCESS); }

void Google::AuditorBase::afterEndRun | ( | INamedInterface * | i ) | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 239 of file GoogleAuditor.cpp.

    { return after(IAuditor::EndRun,i,StatusCode::SUCCESS); }

void Google::AuditorBase::afterExecute | ( | INamedInterface * | i,
|  | const StatusCode & | s
| ) |  | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 237 of file GoogleAuditor.cpp.

    { return after(IAuditor::Execute,i,s); }

void Google::AuditorBase::afterFinalize | ( | INamedInterface * | i ) | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 240 of file GoogleAuditor.cpp.

    { return after(IAuditor::Finalize,i,StatusCode::SUCCESS); }

void Google::AuditorBase::afterInitialize | ( | INamedInterface * | i ) | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 235 of file GoogleAuditor.cpp.

    { return after(IAuditor::Initialize,i,StatusCode::SUCCESS); }

void Google::AuditorBase::afterReinitialize | ( | INamedInterface * | i ) | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 236 of file GoogleAuditor.cpp.

    { return after(IAuditor::ReInitialize,i,StatusCode::SUCCESS); }

virtual bool Google::AuditorBase::alreadyRunning | ( | ) | `[protected, pure virtual]`

check if we are already running the tool

Implemented in Google::HeapProfiler, Google::HeapChecker, and Google::CPUProfiler.

void Google::AuditorBase::before | ( | StandardEventType | type,
|  | const std::string & | s
| ) |  | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 157 of file GoogleAuditor.cpp.

        {
          std::ostringstream t;
          t << type;
          before(t.str(),s);
        }

void Google::AuditorBase::before | ( | CustomEventTypeRef | type,
|  | INamedInterface * | i
| ) |  | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 149 of file GoogleAuditor.cpp.

        {
          if ( !m_skipSequencers || !isSequencer(i) )
          {
            before(type,i->name());
          }
        }

void Google::AuditorBase::before | ( | CustomEventTypeRef | ,
|  | const std::string & | s
| ) |  | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 164 of file GoogleAuditor.cpp.

        {
          if ( !m_fullEventAudit && m_audit &&
               std::find(m_veto.begin(),m_veto.end(),s) == m_veto.end() &&
               ( m_list.empty() || std::find(m_list.begin(),m_list.end(),s) != m_list.end() ) )
          {
            if ( !alreadyRunning() )
            {
              m_log << MSG::INFO << "Starting Auditor for " << s << endmsg;
              m_startedBy = s;
              std::ostringstream t;
              t << s << "-Event" << m_nEvts;
              google_before(t.str());
            }
            else
            {
              m_log << MSG::WARNING
                    << "Auditor already running. Cannot be started for " << s
                    << endmsg;
            }
          }
        }

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

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

Reimplemented from Auditor.

Definition at line 141 of file GoogleAuditor.cpp.

        {
          if ( !m_skipSequencers || !isSequencer(i) )
          {
            before(type,i->name());
          }
        }

void Google::AuditorBase::beforeBeginRun | ( | INamedInterface * | i ) | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 231 of file GoogleAuditor.cpp.

    { return before(IAuditor::BeginRun,i);     }

void Google::AuditorBase::beforeEndRun | ( | INamedInterface * | i ) | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 232 of file GoogleAuditor.cpp.

    { return before(IAuditor::EndRun,i);       }

void Google::AuditorBase::beforeExecute | ( | INamedInterface * | i ) | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 230 of file GoogleAuditor.cpp.

    { return before(IAuditor::Execute,i);      }

void Google::AuditorBase::beforeFinalize | ( | INamedInterface * | i ) | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 233 of file GoogleAuditor.cpp.

    { return before(IAuditor::Finalize,i);     }

void Google::AuditorBase::beforeInitialize | ( | INamedInterface * | i ) | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 228 of file GoogleAuditor.cpp.

    { return before(IAuditor::Initialize,i);   }

void Google::AuditorBase::beforeReinitialize | ( | INamedInterface * | i ) | `[inline, virtual]`

Reimplemented from Auditor.

Definition at line 229 of file GoogleAuditor.cpp.

    { return before(IAuditor::ReInitialize,i); }

StatusCode Google::AuditorBase::finalize | ( | void | ) | `[inline, virtual]`

Finalize the auditor base.

Reimplemented from Auditor.

Definition at line 60 of file GoogleAuditor.cpp.

        {
          if ( alreadyRunning() ) stopAudit();
          return StatusCode::SUCCESS;
        }

virtual void Google::AuditorBase::google_after | ( | const std::string & | s ) | `[protected, pure virtual]`

stop the google tool

Implemented in Google::HeapProfiler, Google::HeapChecker, and Google::CPUProfiler.

virtual void Google::AuditorBase::google_before | ( | const std::string & | s ) | `[protected, pure virtual]`

Start the google tool.

Implemented in Google::HeapProfiler, Google::HeapChecker, and Google::CPUProfiler.

void Google::AuditorBase::handle | ( | const Incident & | incident ) | `[inline, virtual]`

Implement the handle method for the Incident service.

This is used to inform the tool of software incidents.

Parameters:

  incident | The incident identifier

Implements IIncidentListener.

Definition at line 106 of file GoogleAuditor.cpp.

        {
          if ( IncidentType::BeginEvent == incident.type() )
          {
            ++m_nEvts;
            m_audit = ( m_nEvts > m_eventsToSkip &&
                        ( m_freq < 0            ||
                          m_nEvts == 1          ||
                          m_nEvts % m_freq == 0  ) );
            m_log << MSG::DEBUG << "Event " << m_nEvts
                  << " Audit=" << m_audit << endmsg;
            if ( m_fullEventAudit )
            {
              if ( m_inFullAudit )
              {
                if ( m_sampleEventCount >= m_nSampleEvents &&
                     alreadyRunning() )
                {
                  stopAudit();
                }
                else
                {
                  ++m_sampleEventCount;
                }
              }
              if ( m_audit && !m_inFullAudit && !alreadyRunning() )
              {
                startAudit();
              }
            }
          }
        }

StatusCode Google::AuditorBase::initialize | ( | void | ) | `[inline, virtual]`

Initialize the auditor base.

Reimplemented from Auditor.

Reimplemented in Google::HeapChecker.

Definition at line 47 of file GoogleAuditor.cpp.

        {
          m_log << MSG::INFO << "Initialised" << endmsg;

          SmartIF<IIncidentSvc> inSvc(serviceLocator()->service("IncidentSvc"));
          if ( ! inSvc.isValid() ) return StatusCode::FAILURE;

          inSvc->addListener( this, IncidentType::BeginEvent );

          return StatusCode::SUCCESS;
        }

bool Google::AuditorBase::isSequencer | ( | INamedInterface * | i ) | const`[inline, private]`

Check if the component in question is a GaudiSequencer or a Sequencer.

Definition at line 93 of file GoogleAuditor.cpp.

        {
          return ( dynamic_cast<GaudiSequencer*>(i) != NULL ||
                   dynamic_cast<Sequencer*>(i)      != NULL );
        }

void Google::AuditorBase::startAudit | ( | ) | `[inline, private]`

Start a full event audit.

Definition at line 69 of file GoogleAuditor.cpp.

        {
          m_log << MSG::INFO << " -> Starting full audit from event " << m_nEvts << " to "
                << m_nEvts+m_nSampleEvents << endmsg;
          m_inFullAudit = true;
          m_sampleEventCount = 1;
          std::ostringstream t;
          t << "FULL-Events" << m_nEvts << "To" << m_nEvts+m_nSampleEvents ;
          google_before(t.str());
        }

void Google::AuditorBase::stopAudit | ( | ) | `[inline, private]`

stop a full event audit

Definition at line 81 of file GoogleAuditor.cpp.

        {
          m_log << MSG::INFO << " -> Stopping full audit" << endmsg;
          std::ostringstream t;
          t << "FULL-Events" << m_nEvts << "To" << m_nEvts+m_nSampleEvents ;
          google_after(t.str());
          m_inFullAudit = false;
          m_sampleEventCount = 0;
        }

## Member Data Documentation

bool Google::AuditorBase::m_audit`[private]`

Internal flag to say if auditing is enabled or not for the current event.

Definition at line 269 of file GoogleAuditor.cpp.

unsigned long long Google::AuditorBase::m_eventsToSkip`[private]`

Number of events to skip before auditing.

Definition at line 263 of file GoogleAuditor.cpp.

int Google::AuditorBase::m_freq`[private]`

The frequency to audit events. -1 means all events.

Definition at line 267 of file GoogleAuditor.cpp.

bool Google::AuditorBase::m_fullEventAudit`[private]`

Flag to indicate if full event auditing is enabled or not.

Definition at line 273 of file GoogleAuditor.cpp.

bool Google::AuditorBase::m_inFullAudit`[private]`

Internal flag to indicate if we are current in a full event audit.

Definition at line 279 of file GoogleAuditor.cpp.

std::vector<std::string> Google::AuditorBase::m_list`[private]`

Any component in this list will be audited. If empty, all will be done.

Definition at line 261 of file GoogleAuditor.cpp.

MsgStream Google::AuditorBase::m_log`[mutable, protected]`

Messaging object.

Definition at line 255 of file GoogleAuditor.cpp.

unsigned long long Google::AuditorBase::m_nEvts`[private]`

Number of events processed.

Definition at line 271 of file GoogleAuditor.cpp.

unsigned long long Google::AuditorBase::m_nSampleEvents`[private]`

Number of events to include in a full event audit.

Definition at line 275 of file GoogleAuditor.cpp.

unsigned long long Google::AuditorBase::m_sampleEventCount`[private]`

Internal count of the number of events currently processed during an audit.

Definition at line 277 of file GoogleAuditor.cpp.

bool Google::AuditorBase::m_skipSequencers`[private]`

Boolean indicating if sequencers should be skipped or not.

Definition at line 265 of file GoogleAuditor.cpp.

std::string Google::AuditorBase::m_startedBy`[private]`

Name of the component we are currently auditing.

Definition at line 281 of file GoogleAuditor.cpp.

std::vector<std::string> Google::AuditorBase::m_veto`[private]`

Veto list. Any component in this list will not be audited.

Definition at line 260 of file GoogleAuditor.cpp.

std::vector<std::string> Google::AuditorBase::m_when`[private]`

When to audit the algorithms.

Definition at line 259 of file GoogleAuditor.cpp.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v23r1/GaudiProfiling/src/component/google/GoogleAuditor.cpp

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