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

# ChronoStatSvc Class Reference

`#include <ChronoStatSvc.h>`

Inheritance diagram for ChronoStatSvc:

[legend]
Collaboration diagram for ChronoStatSvc:

[legend]

List of all members.

## Detailed Description

The Chrono& Stat Sservice: service implements the IChronoStatSvc interface and provides the basic chronometry and some statistical counts needed by all applications.

Author:
  : Vanya BELYAEV Ivan.Belyaev@itep.ru : December 1, 1999

Definition at line 36 of file ChronoStatSvc.h.

## Public Types
typedef std::map < IChronoStatSvc::ChronoTag, ChronoEntity > | ChronoMap
| some useful typedefs
typedef std::map < IChronoStatSvc::StatTag, StatEntity > | StatMap
## Public Member Functions
virtual StatusCode | initialize ()
| Implementation of IService::initialize().
virtual StatusCode | finalize ()
| Implementation of IService::finalize().
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvi)
| Implementation of IInterface::queryInterface().
virtual ChronoEntity * | chronoStart (const IChronoStatSvc::ChronoTag &chronoTag)
| Implementation of IChronoStatSvc::chronoStart.
virtual const ChronoEntity * | chronoStop (const IChronoStatSvc::ChronoTag &chronoTag)
| Implementation of IChronoStatSvc::chronoStop.
virtual IChronoStatSvc::ChronoTime | chronoDelta (const IChronoStatSvc::ChronoTag &chronoTag, IChronoStatSvc::ChronoType theType)
| Implementation of IchronoStatSvc::chronoDelta.
virtual void | chronoPrint (const IChronoStatSvc::ChronoTag &chronoTag)
| Implementation of IChronoStatSvc::chronoPrint.
virtual ChronoStatus | chronoStatus (const IChronoStatSvc::ChronoTag &chronoTag)
| Implementation of IChronoStatSvc::chronoStatus.
virtual void | stat (const IChronoStatSvc::StatTag &statTag, const IChronoStatSvc::StatFlag &statFlag)
| Implementation of IChronoStatSvc::stat add statistical information to the entity , tagged by its name.
virtual void | statPrint (const IChronoStatSvc::ChronoTag &statTag)
| prints (using message service) info about statistical entity, tagged by its name
virtual const ChronoEntity * | chrono (const IChronoStatSvc::ChronoTag &t) const
| extract the chrono entity for the given tag (name)
virtual const StatEntity * | stat (const IChronoStatSvc::StatTag &t) const
| extract the stat entity for the given tag (name)
| ChronoStatSvc (const std::string &name, ISvcLocator *svcloc)
| Default constructor.
virtual | ~ChronoStatSvc ()
| Destructor.
## Protected Member Functions
void | printStats ()
## Private Member Functions
| ChronoStatSvc ()
| ChronoStatSvc (const ChronoStatSvc &)
ChronoStatSvc & | operator= (const ChronoStatSvc &)
void | saveStats ()
| dump the statistics into an ASCII file for offline processing
## Private Attributes
ChronoMap | m_chronoEntities
| chrono part
int | m_intChronoPrintLevel
| level of info printing
MSG::Level | m_chronoPrintLevel
bool | m_chronoTableFlag
| flag for printing the final table
bool | m_chronoCoutFlag
| flag for destination of the the final table
bool | m_chronoOrderFlag
| flag for formattion the final statistic table
bool | m_printUserTime
| flag for printing User quantities
bool | m_printSystemTime
| flag for printing System quantities
bool | m_printEllapsedTime
| flag for printing Ellapsed quantities
long | m_numberOfSkippedEventsForMemStat
StatMap | m_statEntities
| stat part
int | m_intStatPrintLevel
| level of info printing
MSG::Level | m_statPrintLevel
bool | m_statTableFlag
| flag for printing the final table
bool | m_statCoutFlag
| flag for destination of the t he final table
bool | m_statOrderFlag
| flag for formattion the final statistic table
StringProperty | m_statsOutFileName
| Name of the output file where we'll dump the stats.
std::string | m_header
| the header row
std::string | m_format1
| format for regular statistical printout rows
std::string | m_format2
| format for "efficiency" statistical printout rows
bool | m_useEffFormat
| flag to use the special "efficiency" format

## Member Typedef Documentation

typedef std::map<IChronoStatSvc::ChronoTag,ChronoEntity> ChronoStatSvc::ChronoMap

some useful typedefs

Definition at line 42 of file ChronoStatSvc.h.

typedef std::map<IChronoStatSvc::StatTag,StatEntity> ChronoStatSvc::StatMap

Definition at line 43 of file ChronoStatSvc.h.

## Constructor & Destructor Documentation

ChronoStatSvc::ChronoStatSvc | ( | const std::string & | name,
|  | ISvcLocator * | svcloc |
| ) |  |  |

Default constructor.

Parameters:

  | name | service instance name
  | svcloc | pointer to servcie locator

deside if the final printout should be performed

define the destination of the table to be printed

print level

if printout is to be performed, should one take care about some ordering?

if User Time information to be printed?

if System Time information to be printed?

if Ellapsed Time information to be printed?

deside if the final printout should be performed

define the destination of the table to be printed

print level

if printout is to be performed, should one take care about some ordering?

Definition at line 91 of file ChronoStatSvc.cpp.

    00092   : Service( name , svcloc )
    00093   , m_chronoEntities   ()
    00094   , m_chronoPrintLevel ( MSG::INFO )
    00095   , m_statEntities     ()
    00096   , m_statPrintLevel   ( MSG::INFO )
    00097   //
    00098   // the header row
    00099   , m_header  ( "     Counter     |     #     |    sum     | mean/eff^* | rms/err^*  |     min     |     max     |")
    00100   // format for regular statistical printout rows
    00101   , m_format1 ( " %|-15.15s|%|17t||%|10d| |%|11.7g| |%|#11.5g| |%|#11.5g| |%|#12.5g| |%|#12.5g| |" )
    00102   // format for "efficiency" statistical printout rows
    00103   , m_format2 ( "*%|-15.15s|%|17t||%|10d| |%|11.5g| |(%|#9.7g| +- %|-#9.7g|)%%|   -------   |   -------   |" )
    00104   // flag to use the special "efficiency" format
    00105   , m_useEffFormat ( true )
    00106 {
    00108   declareProperty ( "ChronoPrintOutTable"    ,
    00109                     m_chronoTableFlag      = true      );
    00111   declareProperty ( "ChronoDestinationCout"  ,
    00112                     m_chronoCoutFlag       = false     );
    00114   declareProperty ( "ChronoPrintLevel"       ,
    00115                     m_intChronoPrintLevel  = MSG::INFO );
    00118   declareProperty ( "ChronoTableToBeOrdered" ,
    00119                     m_chronoOrderFlag      = true      );
    00121   declareProperty ( "PrintUserTime"          ,
    00122                     m_printUserTime        = true      );
    00124   declareProperty ( "PrintSystemTime"        ,
    00125                     m_printSystemTime      = false     );
    00127   declareProperty ( "PrintEllapsedTime"      ,
    00128                     m_printEllapsedTime    = false     );
    00131   declareProperty ( "StatPrintOutTable"      ,
    00132                     m_statTableFlag        = true      );
    00134   declareProperty ( "StatDestinationCout"    ,
    00135                     m_statCoutFlag         = false     );
    00137   declareProperty ( "StatPrintLevel"         ,
    00138                     m_intStatPrintLevel    = MSG::INFO );
    00141   declareProperty ( "StatTableToBeOrdered"   ,
    00142                     m_statOrderFlag        = true      );
    00143
    00144   // specify the number of events to be skipped by the memory auditor
    00145   // in order to better spot memory leak
    00146   declareProperty ( "NumberOfSkippedEventsForMemStat"      ,
    00147                     m_numberOfSkippedEventsForMemStat = -1 ) ;
    00148
    00149   declareProperty( "AsciiStatsOutputFile",
    00150                    m_statsOutFileName = "",
    00151                    "Name of the output file storing the stats. If empty, no"
    00152                    " statistics will be saved (default)" );
    00153
    00154   declareProperty
    00155     ( "StatTableHeader"        , m_header                          ,
    00156       "The header row for the output Stat-table"                   ) ;
    00157   declareProperty
    00158     ( "RegularRowFormat"       , m_format1                         ,
    00159       "The format for the regular row in the output Stat-table"    ) ;
    00160   declareProperty
    00161     ( "EfficiencyRowFormat"    , m_format2                         ,
    00162       "The format for the regular row in the outptu Stat-table"    ) ;
    00163   declareProperty
    00164     ( "UseEfficiencyRowFormat" , m_useEffFormat                    ,
    00165       "Use the special format for printout of efficiency counters" ) ;
    00166 }

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

Destructor.

Definition at line 170 of file ChronoStatSvc.cpp.

    00171 {
    00172   // clear the container of chrono entities
    00173   m_chronoEntities.clear();
    00174   // clear the container of stat   entities
    00175   m_statEntities.clear();
    00176 }

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

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

## Member Function Documentation

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

Implementation of IService::initialize().

redefine some "properties"

start its own chrono

Reimplemented from Service.

Definition at line 180 of file ChronoStatSvc.cpp.

    00181 {
    00182   StatusCode sc = Service::initialize();
    00183   if ( sc.isFailure() ) return sc;
    00185   MsgStream log( msgSvc() , this->name() );
    00186
    00187   // Set my own properties
    00188   sc = setProperties();
    00189
    00190   if (sc.isFailure()) {
    00191     log << MSG::ERROR << "setting my properties" << endreq;
    00192     return StatusCode::FAILURE;
    00193   }
    00194
    00195   log << MSG::INFO << " Number of skipped events for MemStat"
    00196       << m_numberOfSkippedEventsForMemStat << endreq ;
    00197
    00201   m_statPrintLevel =
    00202     ( MSG::FATAL < m_intStatPrintLevel   ) ? MSG::FATAL :
    00203     ( MSG::NIL   > m_intStatPrintLevel   ) ? MSG::NIL   :
    00204     ( MSG::Level ) m_intStatPrintLevel  ;
    00206   m_chronoPrintLevel =
    00207     ( MSG::FATAL < m_intChronoPrintLevel ) ? MSG::FATAL :
    00208     ( MSG::NIL   > m_intChronoPrintLevel ) ? MSG::NIL   :
    00209     ( MSG::Level ) m_intChronoPrintLevel ;
    00211   if( m_chronoTableFlag  &&
    00212       !m_printUserTime   &&
    00213       !m_printSystemTime &&
    00214       !m_printEllapsedTime ) { m_printUserTime   = true ; }
    00216   if(  m_printUserTime    ||
    00217        m_printSystemTime  ||
    00218        m_printEllapsedTime ) { m_chronoTableFlag = true ; }
    00221   chronoStart( name() ) ;
    00223   return StatusCode::SUCCESS;
    00224 }

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

Implementation of IService::finalize().

stop its own chrono

Is the final chrono table to be printed?

decoration

CONTINUE

CONTINUE

stop chrono (if it is still in RUNNING status)

print to std::cout

print to MsgStream

decoration

CONTINUE

CONTINUE

stop chrono (if it is still in RUNNING status)

print to std::cout

print to MsgStream

decoration

CONTINUE

CONTINUE

stop chrono (if it is still in RUNNING status)

print to std::cout

print to MsgStream

clear the temporary container

the final decoration

Is the final stat table to be printed?

< finalize the base class

Reimplemented from Service.

Definition at line 228 of file ChronoStatSvc.cpp.

    00229 {
    00230   std::string local = name()+".finalize()";
    00232   MsgStream log( msgSvc() , local );
    00235   chronoStop( name() ) ;
    00236
    00239   if ( m_chronoTableFlag &&
    00240        !m_chronoEntities.empty() &&
    00241        ( m_printUserTime || m_printSystemTime ) )
    00242     {
    00244       MsgStream log( msgSvc() , "*****Chrono*****" );
    00245       const std::string stars( ( m_chronoCoutFlag ) ? 126 : 100  , '*' );
    00246       if( m_chronoCoutFlag  )
    00247         {
    00248           std::cout << stars << std::endl;
    00249           std::cout << local <<  " The Final CPU consumption (Chrono) Table "
    00250                     << ( m_chronoOrderFlag ? "(ordered)" : "(not ordered)" ) << std::endl;
    00251           std::cout << stars << std::endl;
    00252         }
    00253       else
    00254         {
    00255           log << (MSG::Level) m_chronoPrintLevel
    00256         << stars << endreq;
    00257           log << (MSG::Level) m_chronoPrintLevel
    00258         << " The Final CPU consumption ( Chrono ) Table "
    00259               << ( m_chronoOrderFlag ? "(ordered)" : "(not ordered)" ) << endreq;
    00260           log << (MSG::Level) m_chronoPrintLevel << stars << endreq;
    00261         }
    00263       {  // prepare container for printing
    00264         typedef std::pair<ChronoEntity*,const ChronoTag*>        MPair;
    00265         typedef std::vector<MPair>                               MCont;
    00266         MCont tmpCont;
    00267         for( ChronoMap::iterator it = m_chronoEntities.begin() ;
    00268        m_chronoEntities.end() != it ;  ++it )
    00269           { tmpCont.push_back( MPair( &(it->second) , &(it->first) ) ) ; }
    00270         // sort it
    00271         if( m_chronoOrderFlag )
    00272   { std::sort( tmpCont.begin() ,
    00273                tmpCont.end()   ,
    00274                ComparePairOfChronoEntityAndChronoTag() ); }
    00275         // print User Time statistics
    00276         if( m_printUserTime   )
    00277           {
    00278             for( MCont::iterator iter = tmpCont.begin() ;  tmpCont.end() != iter ; ++iter )
    00279               {
    00280                 //
    00281                 ChronoEntity*    entity = iter->first  ; if( 0 == entity ) { continue ; }
    00282                 const ChronoTag* tag    = iter->second ; if( 0 == tag    ) { continue ; }
    00283
    00284                 entity->stop();
    00285
    00286                 if     ( m_chronoCoutFlag )
    00287                   { std::cout << *tag << "\t"  << entity->outputUserTime  () << std::endl ; }
    00288                 else
    00289                   {
    00290                     MsgStream log( msgSvc() , *tag ) ;
    00291                     log << m_chronoPrintLevel << entity->outputUserTime  () << endreq ;
    00292                   }
    00293                 //
    00294               }
    00295           }
    00297         if( m_printSystemTime )
    00298           {
    00301             if      ( m_printUserTime && m_chronoCoutFlag   )
    00302               { std::cout << stars << std::endl;                           }
    00303             else if ( m_printUserTime && !m_chronoCoutFlag  )
    00304               { log << (MSG::Level) m_chronoPrintLevel << stars << endreq; }
    00306             for( MCont::iterator iter = tmpCont.begin() ;  tmpCont.end() != iter ; ++iter )
    00307               {
    00309                 ChronoEntity*    entity = iter->first  ; if( 0 == entity ) { continue ; }
    00310                 const ChronoTag* tag    = iter->second ; if( 0 == tag    ) { continue ; }
    00311
    00312                 entity->stop();
    00313
    00314                 if     ( m_chronoCoutFlag )
    00315                   { std::cout << *tag << "\t"  << entity->outputSystemTime() << std::endl ; }
    00316                 else
    00317                   {
    00318                     MsgStream log( msgSvc() , *tag ) ;
    00319                     log << m_chronoPrintLevel << entity->outputSystemTime() << endreq ;
    00320                   }
    00321                 //
    00322               }
    00323           }
    00325         if( m_printEllapsedTime )
    00326           {
    00329             if      ( ( m_printUserTime || m_printSystemTime ) &&  m_chronoCoutFlag  )
    00330               { std::cout << stars << std::endl;                           }
    00331             else if ( ( m_printUserTime || m_printSystemTime ) && !m_chronoCoutFlag  )
    00332               { log << (MSG::Level) m_chronoPrintLevel << stars << endreq; }
    00334             for( MCont::iterator iter = tmpCont.begin() ;  tmpCont.end() != iter ; ++iter )
    00335               {
    00337                 ChronoEntity*    entity = iter->first  ; if( 0 == entity ) { continue ; }
    00338                 const ChronoTag* tag    = iter->second ; if( 0 == tag    ) { continue ; }
    00339
    00340                 entity->stop();
    00341
    00342                 if     ( m_chronoCoutFlag )
    00343                   { std::cout << *tag << "\t"  << entity->outputElapsedTime() << std::endl ; }
    00344                 else
    00345                   {
    00346                     MsgStream log( msgSvc() , *tag ) ;
    00347                     log << m_chronoPrintLevel << entity->outputElapsedTime() << endreq ;
    00348                   }
    00349                 //
    00350               }
    00351           }
    00353         tmpCont.clear();
    00354       }
    00356       if( m_chronoCoutFlag  ) { std::cout << stars << std::endl;              }
    00357       else                    { log << m_chronoPrintLevel << stars << endreq; }
    00358     }
    00359
    00361
    00363   if ( m_statTableFlag ) { printStats () ; }
    00364
    00365   if ( !m_statsOutFileName.value().empty() ) {
    00366     saveStats();
    00367   }
    00368
    00369   log << MSG::INFO << " Service finalized succesfully " << endreq;
    00370
    00371   return Service::finalize();
    00372 }

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

Implementation of IInterface::queryInterface().

Reimplemented from Service.

Definition at line 378 of file ChronoStatSvc.cpp.

    00380 {
    00381   if ( 0 == ppvInterface ) { return StatusCode::FAILURE ; }
    00382   else if ( IChronoSvc::interfaceID()     == riid )
    00383   { *ppvInterface = static_cast<IChronoSvc*>     (this) ; }
    00384   else if ( IStatSvc::interfaceID()       == riid )
    00385   { *ppvInterface = static_cast<IStatSvc*>       (this) ; }
    00386   else if ( IChronoStatSvc::interfaceID() == riid )
    00387   { *ppvInterface = static_cast<IChronoStatSvc*> (this) ; }
    00388   else { return Service::queryInterface(riid, ppvInterface) ; }
    00389   addRef();
    00390   return StatusCode::SUCCESS;
    00391 }

ChronoEntity * ChronoStatSvc::chronoStart | ( | const IChronoStatSvc::ChronoTag & | chronoTag | ) | `[virtual]`

Implementation of IChronoStatSvc::chronoStart.

See also:
  IChronoStatSvc

Implements IChronoSvc.

Definition at line 397 of file ChronoStatSvc.cpp.

    00398 {
    00399   ChronoEntity& entity = m_chronoEntities [ chronoTag ] ;
    00400   entity.start() ;
    00401   return &entity ;
    00402 }

const ChronoEntity * ChronoStatSvc::chronoStop | ( | const IChronoStatSvc::ChronoTag & | chronoTag | ) | `[virtual]`

Implementation of IChronoStatSvc::chronoStop.

See also:
  IChronoStatSvc

Implements IChronoSvc.

Definition at line 408 of file ChronoStatSvc.cpp.

    00409 {
    00410   ChronoEntity& entity = m_chronoEntities [ chronoTag ] ;
    00411   entity.stop() ;
    00412   return &entity ;
    00413 }

IChronoStatSvc::ChronoTime ChronoStatSvc::chronoDelta | ( | const IChronoStatSvc::ChronoTag & | chronoTag,
|  | IChronoStatSvc::ChronoType | theType |
| ) |  |  | `[virtual]`

Implementation of IchronoStatSvc::chronoDelta.

See also:
  IChronoStatSvc

Implements IChronoSvc.

Definition at line 419 of file ChronoStatSvc.cpp.

    00421 {
    00422   return m_chronoEntities[ chronoTag ].delta( theType );
    00423 }

void ChronoStatSvc::chronoPrint | ( | const IChronoStatSvc::ChronoTag & | chronoTag | ) | `[virtual]`

Implementation of IChronoStatSvc::chronoPrint.

See also:
  IChronoStatSvc

Implements IChronoSvc.

Definition at line 428 of file ChronoStatSvc.cpp.

    00429 {
    00430   MsgStream log ( msgSvc() , chronoTag );
    00431   if( m_printUserTime   ) {
    00432     log << (MSG::Level) m_chronoPrintLevel
    00433         << m_chronoEntities[ chronoTag ].outputUserTime  ()
    00434         << endreq;
    00435   }
    00436   if( m_printSystemTime ) {
    00437     log << (MSG::Level) m_chronoPrintLevel
    00438         << m_chronoEntities[ chronoTag ].outputSystemTime()
    00439         << endreq;
    00440   }
    00441 }

IChronoStatSvc::ChronoStatus ChronoStatSvc::chronoStatus | ( | const IChronoStatSvc::ChronoTag & | chronoTag | ) | `[virtual]`

Implementation of IChronoStatSvc::chronoStatus.

See also:
  IChronoStatSvc

Implements IChronoSvc.

Definition at line 447 of file ChronoStatSvc.cpp.

    00448 { return m_chronoEntities[ chronoTag ].status(); }

void ChronoStatSvc::stat | ( | const IChronoStatSvc::StatTag & | statTag,
|  | const IChronoStatSvc::StatFlag & | statFlag |
| ) |  |  | `[virtual]`

Implementation of IChronoStatSvc::stat add statistical information to the entity , tagged by its name.

See also:
  IChronoStatSvc

Definition at line 453 of file ChronoStatSvc.cpp.

    00455 {
    00456   StatMap::iterator theIter=m_statEntities.find(statTag);
    00457
    00458   StatEntity * theStat=0 ;
    00459   // if new entity, specify the neumber of events to be skipped
    00460   if (theIter==m_statEntities.end()){
    00461     // new stat entity
    00462     StatEntity& theSe = m_statEntities[ statTag ];
    00463     theStat=& theSe;
    00464     theStat->setnEntriesBeforeReset(m_numberOfSkippedEventsForMemStat);
    00465   }
    00466   else
    00467   {
    00468     //existing stat entity
    00469     theStat=&((*theIter).second);
    00470   }
    00471
    00472   theStat->addFlag ( statFlag ) ;
    00473 }

void ChronoStatSvc::statPrint | ( | const IChronoStatSvc::ChronoTag & | statTag | ) | `[virtual]`

prints (using message service) info about statistical entity, tagged by its name

See also:
  IChronoStatSvc

Implements IStatSvc.

Definition at line 478 of file ChronoStatSvc.cpp.

    00479 {
    00480   MsgStream log ( msgSvc() , statTag ) ;
    00481   log << (MSG::Level) m_statPrintLevel << m_statEntities[ statTag ] << endreq;
    00482 }

const ChronoEntity * ChronoStatSvc::chrono | ( | const IChronoStatSvc::ChronoTag & | t | ) | const`[virtual]`

extract the chrono entity for the given tag (name)

See also:
  IChronoStatSvc

Parameters:

  | t | chrono tag(name)

Returns:
  pointer to chrono entity

Implements IChronoSvc.

Definition at line 491 of file ChronoStatSvc.cpp.

    00492 {
    00493   ChronoMap::const_iterator it = m_chronoEntities.find ( t ) ;
    00494   if ( m_chronoEntities.end() != it ) { return &(it->second) ; }
    00495   return 0 ;
    00496 }

const StatEntity * ChronoStatSvc::stat | ( | const IChronoStatSvc::StatTag & | t | ) | const`[virtual]`

extract the stat entity for the given tag (name)

See also:
  IChronoStatSvc

Parameters:

  | t | stat tag(name)

Returns:
  pointer to stat entity

Implements IStatSvc.

Definition at line 505 of file ChronoStatSvc.cpp.

    00506 {
    00507   StatMap::const_iterator it = m_statEntities.find ( t ) ;
    00508   if ( m_statEntities.end() != it ) { return &(it->second) ; }
    00509   return 0 ;
    00510 }

void ChronoStatSvc::printStats | ( |  | ) | `[protected]`

nothing to print?

CONTINUE

CONTINUE

decoration

Definition at line 592 of file ChronoStatSvc.cpp.

    00593 {
    00595   if ( m_statEntities.empty() ) { return ; }
    00596
    00597   MsgStream log ( msgSvc() , "******Stat******" ) ;
    00599   const std::string stars( ( m_statCoutFlag ) ? 126 : 100  , '*' ) ;
    00601   if ( m_statCoutFlag  )
    00602         {
    00603           std::cout << stars << std::endl;
    00604           std::cout <<  " The Final stat Table "
    00605               << ( m_statOrderFlag ? "(ordered)" : "(not ordered)" ) << std::endl;
    00606           std::cout << stars << std::endl;
    00607         }
    00608   else
    00609   {
    00610           log << m_statPrintLevel << stars << endreq;
    00611           log <<  m_statPrintLevel << " The Final stat Table "
    00612               << ( m_statOrderFlag ? "(ordered)" : "(not ordered)" ) << endreq;
    00613           log << m_statPrintLevel << stars << endreq;
    00614         }
    00615
    00616   {
    00617     // prepare container for printing
    00618     typedef std::pair<const StatEntity*,const StatTag*>  SPair;
    00619     typedef std::vector<SPair>                           SCont;
    00620     SCont tmpCont;
    00621     for( StatMap::const_iterator it = m_statEntities.begin();
    00622          it != m_statEntities.end(); it++ )
    00623     { tmpCont.push_back( SPair( &(it->second) , &(it->first) ) ) ; }
    00624     // sort it
    00625     if ( m_statOrderFlag )
    00626     { std::sort( tmpCont.begin() ,
    00627                  tmpCont.end()   ,
    00628                  ComparePairOfStatEntityAndStatTag() ); }
    00629
    00630
    00631     {
    00632       // print the table header
    00633       if ( m_statCoutFlag ) { std::cout <<                     m_header << std::endl ; }
    00634       else                  { log       << m_statPrintLevel << m_header << endreq    ; }
    00635     }
    00636     // loop over counters and print them:
    00637     for ( SCont::iterator iter = tmpCont.begin() ; tmpCont.end() != iter ; ++iter )
    00638           {
    00640       const StatEntity* entity = iter->first  ;
    00641       if ( 0 == entity ) { continue ; }
    00642       const StatTag*    tag    = iter->second ;
    00643       if ( 0 == tag    ) { continue ; }
    00644
    00645             if ( m_statCoutFlag )
    00646       {
    00647         std::cout
    00648           << Gaudi::Utils::formatAsTableRow
    00649           ( *tag , *entity , m_useEffFormat , m_format1 , m_format2 )
    00650           << std::endl;
    00651       }
    00652             else
    00653       {
    00654         log
    00655           << m_statPrintLevel
    00656           << Gaudi::Utils::formatAsTableRow
    00657           ( *tag , *entity , m_useEffFormat , m_format1 , m_format2 )
    00658           << endreq ;
    00659       }
    00660           }
    00661     tmpCont.clear();
    00662   }
    00664   if ( m_statCoutFlag  ) { std::cout << stars << std::endl;            }
    00665   else                   { log << m_statPrintLevel << stars << endreq; }
    00666 }

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

void ChronoStatSvc::saveStats | ( |  | ) | `[private]`

dump the statistics into an ASCII file for offline processing

CONTINUE

CONTINUE

Definition at line 514 of file ChronoStatSvc.cpp.

    00515 {
    00516   std::ofstream out( m_statsOutFileName.value().c_str(),
    00517                      std::ios_base::out | std::ios_base::trunc );
    00518   if ( !out.good() ) {
    00519     MsgStream msg( msgSvc() , name() );
    00520     msg << MSG::INFO
    00521         << "Could not open the output file for writing chrono statistics ["
    00522         << m_statsOutFileName.value() << "]"
    00523         << endreq;
    00524     return;
    00525   } else {
    00526     // format it our way
    00527     out << std::scientific << std::setprecision(8) ;
    00528   }
    00529
    00530   // ChronoEntity
    00531   typedef std::pair<ChronoEntity*, const ChronoTag*> MPair;
    00532   typedef std::vector<MPair>                         MCont;
    00533   MCont chronos;
    00534
    00535   for( ChronoMap::iterator it = m_chronoEntities.begin() ;
    00536        m_chronoEntities.end() != it ;  ++it ) {
    00537     chronos.push_back( MPair( &(it->second) , &(it->first) ) ) ;
    00538   }
    00539
    00540   // sort it
    00541   std::sort( chronos.begin() ,
    00542              chronos.end()   ,
    00543              ComparePairOfChronoEntityAndChronoTag() );
    00544
    00545   // print User Time statistics
    00546   for( MCont::iterator iter = chronos.begin() ;
    00547        chronos.end() != iter;
    00548        ++iter ) {
    00549     //
    00550     const ChronoEntity*    entity = iter->first;
    00551     if( 0 == entity ) { continue ; }
    00552
    00553     const ChronoTag* tag    = iter->second ;
    00554     if( 0 == tag    ) { continue ; }
    00555
    00556     // create an entry in the .INI-like table
    00557     out << "\n[" << *tag << "]\n";
    00558
    00559     // user
    00560     out << "cpu_user_total = " << entity->uTotalTime() << "\n";
    00561     out << "cpu_user_min = "   << entity->uMinimalTime() << "\n";
    00562     out << "cpu_user_mean = "  << entity->uMeanTime() << "\n";
    00563     out << "cpu_user_RMS = "   << entity->uRMSTime() << "\n";
    00564     out << "cpu_user_max = "   << entity->uMaximalTime() << "\n";
    00565     out << "cpu_user_nbr = "   << entity->nOfMeasurements() << "\n";
    00566
    00567     // system
    00568     out << "\n"; // just for clarity
    00569     out << "cpu_system_total = " << entity->kTotalTime() << "\n";
    00570     out << "cpu_system_min = "   << entity->kMinimalTime() << "\n";
    00571     out << "cpu_system_mean = "  << entity->kMeanTime() << "\n";
    00572     out << "cpu_system_RMS = "   << entity->kRMSTime() << "\n";
    00573     out << "cpu_system_max = "   << entity->kMaximalTime() << "\n";
    00574     out << "cpu_system_nbr = "   << entity->nOfMeasurements() << "\n";
    00575
    00576     // real
    00577     out << "\n"; // just for clarity
    00578     out << "cpu_real_total = " << entity->eTotalTime() << "\n";
    00579     out << "cpu_real_min = "   << entity->eMinimalTime() << "\n";
    00580     out << "cpu_real_mean = "  << entity->eMeanTime() << "\n";
    00581     out << "cpu_real_RMS = "   << entity->eRMSTime() << "\n";
    00582     out << "cpu_real_max = "   << entity->eMaximalTime() << "\n";
    00583     out << "cpu_real_nbr = "   << entity->nOfMeasurements() << "\n";
    00584
    00585   }
    00586
    00587   out << std::endl;
    00588 }

## Member Data Documentation

ChronoMap ChronoStatSvc::m_chronoEntities`[private]`

chrono part

Definition at line 147 of file ChronoStatSvc.h.

int ChronoStatSvc::m_intChronoPrintLevel`[private]`

level of info printing

Definition at line 149 of file ChronoStatSvc.h.

MSG::Level ChronoStatSvc::m_chronoPrintLevel`[private]`

Definition at line 150 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_chronoTableFlag`[private]`

flag for printing the final table

Definition at line 152 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_chronoCoutFlag`[private]`

flag for destination of the the final table

Definition at line 154 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_chronoOrderFlag`[private]`

flag for formattion the final statistic table

Definition at line 156 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_printUserTime`[private]`

flag for printing User quantities

Definition at line 158 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_printSystemTime`[private]`

flag for printing System quantities

Definition at line 160 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_printEllapsedTime`[private]`

flag for printing Ellapsed quantities

Definition at line 162 of file ChronoStatSvc.h.

long ChronoStatSvc::m_numberOfSkippedEventsForMemStat`[private]`

Definition at line 165 of file ChronoStatSvc.h.

StatMap ChronoStatSvc::m_statEntities`[private]`

stat part

Definition at line 168 of file ChronoStatSvc.h.

int ChronoStatSvc::m_intStatPrintLevel`[private]`

level of info printing

Definition at line 171 of file ChronoStatSvc.h.

MSG::Level ChronoStatSvc::m_statPrintLevel`[private]`

Definition at line 172 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_statTableFlag`[private]`

flag for printing the final table

Definition at line 174 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_statCoutFlag`[private]`

flag for destination of the t he final table

Definition at line 176 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_statOrderFlag`[private]`

flag for formattion the final statistic table

Definition at line 178 of file ChronoStatSvc.h.

StringProperty ChronoStatSvc::m_statsOutFileName`[private]`

Name of the output file where we'll dump the stats.

Definition at line 182 of file ChronoStatSvc.h.

std::string ChronoStatSvc::m_header`[private]`

the header row

Definition at line 185 of file ChronoStatSvc.h.

std::string ChronoStatSvc::m_format1`[private]`

format for regular statistical printout rows

Definition at line 187 of file ChronoStatSvc.h.

std::string ChronoStatSvc::m_format2`[private]`

format for "efficiency" statistical printout rows

Definition at line 189 of file ChronoStatSvc.h.

bool ChronoStatSvc::m_useEffFormat`[private]`

flag to use the special "efficiency" format

Definition at line 191 of file ChronoStatSvc.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r4/GaudiSvc/src/ChronoStatSvc/ChronoStatSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r4/GaudiSvc/src/ChronoStatSvc/ChronoStatSvc.cpp