| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Public Member Functions | Protected Member Functions | Private Attributes

# ChronoEntity Class Reference

a small helper class for implementation of ChronoStatSvc service, It also could be used as some local timer More...

`#include <GaudiKernel/ChronoEntity.h>`

Collaboration diagram for ChronoEntity:
[legend]

List of all members.

## Public Member Functions
| ChronoEntity ()
| default constructor
| ~ChronoEntity ()
| destructor
IChronoSvc::ChronoStatus | start ()
| start the current chrono
IChronoSvc::ChronoStatus | stop ()
| stop the chrono
IChronoSvc::ChronoTime | delta (IChronoSvc::ChronoType type) const
| return the last delta-time of type "type"
IChronoSvc::ChronoStatus | status () const
| return the status of chrono
unsigned long | nOfMeasurements () const
| number of chrono measurements
double | uMinimalTime () const
| minimal measurement for user time
double | kMinimalTime () const
| minimal measurement for kernel time
double | eMinimalTime () const
| minimal measurement for ellapsed time
double | uMaximalTime () const
| maximal measurement for user time
double | kMaximalTime () const
| maximal measurement for kernel time
double | eMaximalTime () const
| maximal measurement for ellapsed time
double | uTotalTime () const
| total user time
double | kTotalTime () const
| total Kernel time
double | eTotalTime () const
| total Elapsed time
double | totalTime () const
| total time
double | kMeanTime () const
| average Kernel Time
double | uMeanTime () const
| average User Time
double | eMeanTime () const
| average Elapsed Time
double | kRMSTime () const
| r.m.s Kernel Time
double | uRMSTime () const
| r.m.s User Time
double | eRMSTime () const
| r.m.s Elapsed Time
double | kMeanErrorTime () const
| error in mean Kernel time
double | uMeanErrorTime () const
| error in mean User time
double | eMeanErrorTime () const
| error in mean Elapsed time
bool | operator< (const ChronoEntity &entity) const
| comparison operator
std::string | outputUserTime () const
| print the chrono ;
std::string | outputSystemTime () const
| print the chrono ;
std::string | outputElapsedTime () const
| print the chrono ;
std::string | outputUserTime (const std::string &fmt, System::TimeType unit) const
| print the chrono according the format and units
std::string | outputSystemTime (const std::string &fmt, System::TimeType unit) const
| print the chrono according the format and units
std::string | outputElapsedTime (const std::string &fmt, System::TimeType unit) const
| print the chrono according the format and units
std::string | outputTime (IChronoSvc::ChronoType typ, const std::string &fmt, System::TimeType unit) const
| print the chrono according the format and units
## Protected Member Functions
std::string | format (const double total, const double minimal, const double mean, const double rms, const double maximal, const unsigned long number) const
| format
## Private Attributes
IChronoSvc::ChronoStatus | m_status
| current status of this chrono object;
IChronoSvc::ChronoTime | m_delta_user
| delta user time
IChronoSvc::ChronoTime | m_delta_kernel
| delta Kernel time
IChronoSvc::ChronoTime | m_delta_elapsed
| delta Elapsed time
IChronoSvc::ChronoTime | m_start_user
| start stamp for current measurement of user time
IChronoSvc::ChronoTime | m_start_kernel
| start stamp for current measurement of Kernel time
IChronoSvc::ChronoTime | m_start_elapsed
| start stamp for current measurement of Elapsed time
StatEntity | m_user
| the actual storage of "user" time
StatEntity | m_kernel
| the actual storage of "kernel" time
StatEntity | m_elapsed
| the actual storage of "elapsed" time

## Detailed Description

a small helper class for implementation of ChronoStatSvc service, It also could be used as some local timer

Author:
  Vanya BELYAEV Ivan.Belyaev@itep.ru

Date:
  December 1, 1999

Definition at line 23 of file ChronoEntity.h.

## Constructor & Destructor Documentation

ChronoEntity::ChronoEntity | ( | ) |

default constructor

current status of this chrono object;

Definition at line 50 of file ChronoEntity.cpp.

      : m_status        ( IChronoSvc::UNKNOWN )  // current status
      , m_delta_user    ( -1 ) // delta user time
      , m_delta_kernel  ( -1 ) // delta kernel time
      , m_delta_elapsed ( -1 ) // delta elapsed time
      , m_start_user    (  0 ) // start for user
      , m_start_kernel  (  0 ) // start for kernel
      , m_start_elapsed (  0 ) // start for elapsed
    {}

ChronoEntity::~ChronoEntity | ( | ) | `[inline]`

destructor

Definition at line 29 of file ChronoEntity.h.

    {};

## Member Function Documentation

IChronoSvc::ChronoTime ChronoEntity::delta | ( | IChronoSvc::ChronoType | type ) | const`[inline]`

return the last delta-time of type "type"

Definition at line 303 of file ChronoEntity.h.

    {
      const IChronoSvc::ChronoTime result = -1 ;
      switch ( type )
      {
      case IChronoSvc::USER    : return m_delta_user    ;
      case IChronoSvc::KERNEL  : return m_delta_kernel  ;
      case IChronoSvc::ELAPSED : return m_delta_elapsed ;
      default                  : return result          ;
      }
      // cannot reach this point
    }

double ChronoEntity::eMaximalTime | ( | ) | const`[inline]`

maximal measurement for ellapsed time

Definition at line 232 of file ChronoEntity.h.

    { return m_elapsed . flagMax () ; }

double ChronoEntity::eMeanErrorTime | ( | ) | const`[inline]`

error in mean Elapsed time

Definition at line 298 of file ChronoEntity.h.

    { return m_elapsed . flagMeanErr () ; }

double ChronoEntity::eMeanTime | ( | ) | const`[inline]`

average Elapsed Time

Definition at line 268 of file ChronoEntity.h.

    { return m_elapsed . flagMean () ; }

double ChronoEntity::eMinimalTime | ( | ) | const`[inline]`

minimal measurement for ellapsed time

Definition at line 217 of file ChronoEntity.h.

    { return m_elapsed. flagMin () ; }

double ChronoEntity::eRMSTime | ( | ) | const`[inline]`

r.m.s Elapsed Time

Definition at line 283 of file ChronoEntity.h.

    { return m_elapsed . flagRMS () ; }

double ChronoEntity::eTotalTime | ( | ) | const`[inline]`

total Elapsed time

Definition at line 247 of file ChronoEntity.h.

    { return m_elapsed . flag () ; }

std::string ChronoEntity::format | ( | const double | total,
|  | const double | minimal,
|  | const double | mean,
|  | const double | rms,
|  | const double | maximal,
|  | const unsigned long | number
| ) |  | const`[protected]`

format

Todo:
  : cache the format

Todo:
  : cache the format

Definition at line 163 of file ChronoEntity.cpp.

    {

      boost::format fmt("Tot=%2$5.3g%1$s %4$43s #=%3$3lu");

      long double  unit = 1.0 ;

      if     ( total / microsecond  <  500 )
      { unit = microsecond ; fmt % " [us]" ; }
      else if( total / millisecond  <  500 )
      { unit = millisecond ; fmt % " [ms]" ; }
      else if( total /      second  <  500 )
      { unit =      second ; fmt % "  [s]" ; }
      else if( total /      minute  <  500 )
      { unit =      minute ; fmt % "[min]" ; }
      else if( total /        hour  <  500 )
      { unit =        hour ; fmt % "  [h]" ; }
      else if( total /         day  <   10 )
      { unit =         day ; fmt % "[day]" ; }
      else if( total /        week  <    5 )
      { unit =        week ; fmt % "  [w]" ; }
      else if( total /       month  <   20 )
      { unit =       month ; fmt % "[mon]" ; }
      else
      { unit =        year ; fmt % "  [y]" ; }

      fmt % (double) (total / unit) % number;

      if( 1 < number )
      {
        boost::format fmt1("Ave/Min/Max=%2$5.3g(+-%3$5.3g)/%4$5.3g/%5$5.3g%1$s");
        if     ( mean / microsecond  <  500 )
        { unit = microsecond ; fmt1 % " [us]" ; }
        else if( mean / millisecond  <  500 )
        { unit = millisecond ; fmt1 % " [ms]" ; }
        else if( mean /      second  <  500 )
        { unit =      second ; fmt1 % "  [s]" ; }
        else if( mean /      minute  <  500 )
        { unit =      minute ; fmt1 % "[min]" ; }
        else if( mean /        hour  <  500 )
        { unit =        hour ; fmt1 % "  [h]" ; }
        else if( mean /         day  <   10 )
        { unit =         day ; fmt1 % "[day]" ; }
        else if( mean /        week  <    5 )
        { unit =        week ; fmt1 % "  [w]" ; }
        else if( mean /       month  <   20 )
        { unit =       month ; fmt1 % "[mon]" ; }
        else
        { unit =        year ; fmt1 % "  [y]" ; }

        fmt1 % (double) ( mean / unit ) % (double) ( rms  / unit )
             % (double) ( minimal  / unit ) % (double) ( maximal  / unit );
        fmt % fmt1.str();
      }
      else {
        fmt % "";
      }

      return fmt.str();
    }

double ChronoEntity::kMaximalTime | ( | ) | const`[inline]`

maximal measurement for kernel time

Definition at line 227 of file ChronoEntity.h.

    { return m_kernel . flagMax () ; }

double ChronoEntity::kMeanErrorTime | ( | ) | const`[inline]`

error in mean Kernel time

Definition at line 288 of file ChronoEntity.h.

    { return m_kernel  . flagMeanErr () ; }

double ChronoEntity::kMeanTime | ( | ) | const`[inline]`

average Kernel Time

Definition at line 258 of file ChronoEntity.h.

    { return m_kernel  . flagMean () ; }

double ChronoEntity::kMinimalTime | ( | ) | const`[inline]`

minimal measurement for kernel time

Definition at line 212 of file ChronoEntity.h.

    { return m_kernel . flagMin () ; }

double ChronoEntity::kRMSTime | ( | ) | const`[inline]`

r.m.s Kernel Time

Definition at line 273 of file ChronoEntity.h.

    { return m_kernel  . flagRMS  () ; }

double ChronoEntity::kTotalTime | ( | ) | const`[inline]`

total Kernel time

Definition at line 242 of file ChronoEntity.h.

    { return m_kernel  . flag () ; }

unsigned long ChronoEntity::nOfMeasurements | ( | ) | const`[inline]`

number of chrono measurements

Definition at line 202 of file ChronoEntity.h.

    { return m_user   . nEntries() ; }

bool ChronoEntity::operator< | ( | const ChronoEntity & | entity ) | const

comparison operator

Definition at line 233 of file ChronoEntity.cpp.

    {
      return
        ( &e           == this          ) ? false :
        ( totalTime () < e.totalTime () ) ? true  :
        ( totalTime () > e.totalTime () ) ? false :
        ( m_user       < e.m_user       ) ? true  :
        ( e.m_user     <   m_user       ) ? false :
        ( m_kernel     < e.m_kernel     ) ? true  :
        ( e.m_kernel   <   m_kernel     ) ? false :
        ( m_elapsed    < e.m_elapsed    ) ? true  :
        ( e.m_elapsed  <   m_elapsed    ) ? false : false ;
    }

std::string ChronoEntity::outputElapsedTime | ( | ) | const

print the chrono ;

Definition at line 148 of file ChronoEntity.cpp.

    {
      std::string res ("TimeElapsed: ") ;
      return res += format
        ( eTotalTime     () ,
          eMinimalTime   () ,
          eMeanTime      () ,
          eRMSTime       () ,
          eMaximalTime   () ,
          nOfMeasurements() );
    }

std::string ChronoEntity::outputElapsedTime | ( | const std::string & | fmt,
|  | System::TimeType | unit
| ) |  | const`[inline]`

print the chrono according the format and units

Parameters:

  fmt | the format string
  unit | the unit

Returns:
  the string representations

See also:
  boost::format

Definition at line 355 of file ChronoEntity.h.

    {
      return outputTime ( IChronoSvc::ELAPSED , fmt , unit ) ;
    }

std::string ChronoEntity::outputSystemTime | ( | const std::string & | fmt,
|  | System::TimeType | unit
| ) |  | const`[inline]`

print the chrono according the format and units

Parameters:

  fmt | the format string
  unit | the unit

Returns:
  the string representations

See also:
  boost::format

Definition at line 340 of file ChronoEntity.h.

    {
      return outputTime ( IChronoSvc::KERNEL , fmt , unit ) ;
    }

std::string ChronoEntity::outputSystemTime | ( | ) | const

print the chrono ;

Definition at line 135 of file ChronoEntity.cpp.

    {
      std::string res ("Time System : ") ;
      return res += format
        ( kTotalTime     () ,
          kMinimalTime   () ,
                            kMeanTime      () ,
                            kRMSTime       () ,
                            kMaximalTime   () ,
                            nOfMeasurements() );
    }

std::string ChronoEntity::outputTime | ( | IChronoSvc::ChronoType | typ,
|  | const std::string & | fmt,
|  | System::TimeType | unit
| ) |  | const

print the chrono according the format and units

The format fields are:

1. number of entries
2. total time (in the specified units)
3. mean time (in the specified units)
4. r.m.s. time (in the specified units)
5. error in mean time (in the specified units)
6. minimal time (in the specified units)
7. maximal time (in the specified units)

Parameters:

  typ | the chrono type
  fmt | the format string
  unit | the unit

Returns:
  the string representations

See also:
  boost::format

Definition at line 256 of file ChronoEntity.cpp.

    {
      boost::format _fmt ( fmt ) ;
      // allow various number of arguments
      using namespace boost::io ;
      _fmt.exceptions ( all_error_bits ^ ( too_many_args_bit | too_few_args_bit ) ) ;
      //
      double _unit = microsecond ;
      switch ( unit )
      {
      case System::Year     : _unit = year        ; break ;
      case System::Month    : _unit = month       ; break ;
      case System::Day      : _unit = day         ; break ;
      case System::Hour     : _unit = hour        ; break ;
      case System::Min      : _unit = minute      ; break ;
      case System::Sec      : _unit = second      ; break ;
      case System::milliSec : _unit = millisecond ; break ;
      case System::microSec : _unit = microsecond ; break ;
      case System::nanoSec  : _unit = nanosecond  ; break ;
      default               : _unit = microsecond ; break ;
      }
      //
      const StatEntity* stat = &m_user;
      switch ( typ )
      {
      case IChronoSvc::USER    : stat = &m_user    ; break ;
      case IChronoSvc::KERNEL  : stat = &m_kernel  ; break ;
      case IChronoSvc::ELAPSED : stat = &m_elapsed ; break ;
      default                  : stat = &m_user    ; break ;
      }
      //
      _fmt
        %   ( stat -> nEntries    ()         )   // %1 : #entries
        %   ( stat -> flag        () / _unit )   // %2 : total time
        %   ( stat -> flagMean    () / _unit )   // %3 : mean time
        %   ( stat -> flagRMS     () / _unit )   // %4 : RMS  time
        %   ( stat -> flagMeanErr () / _unit )   // %5 : error in mean time
        %   ( stat -> flagMin     () / _unit )   // %6 : minimal time
        %   ( stat -> flagMax     () / _unit ) ; // %7 : maximal time
      //
      return _fmt.str() ;
    }

std::string ChronoEntity::outputUserTime | ( | const std::string & | fmt,
|  | System::TimeType | unit
| ) |  | const`[inline]`

print the chrono according the format and units

Parameters:

  fmt | the format string
  unit | the unit

Returns:
  the string representations

See also:
  boost::format

Definition at line 325 of file ChronoEntity.h.

    {
      return outputTime ( IChronoSvc::USER , fmt , unit ) ;
    }

std::string ChronoEntity::outputUserTime | ( | ) | const

print the chrono ;

Definition at line 121 of file ChronoEntity.cpp.

    {
      std::string res ("Time User   : ") ;
      return res += format
        ( uTotalTime     () ,
          uMinimalTime   () ,
          uMeanTime      () ,
          uRMSTime       () ,
          uMaximalTime   () ,
          nOfMeasurements() );
    }

IChronoSvc::ChronoStatus ChronoEntity::start | ( | ) |

start the current chrono

Definition at line 74 of file ChronoEntity.cpp.

    {
      if ( IChronoSvc::RUNNING == m_status ) { return m_status ; }
      //
      // following lines could be platform dependent!
      //
      // Store in object the measured times
      m_start_user    = static_cast<IChronoSvc::ChronoTime>(System::userTime     ( MyUnit ));
      m_start_kernel  = static_cast<IChronoSvc::ChronoTime>(System::kernelTime   ( MyUnit ));
      m_start_elapsed = static_cast<IChronoSvc::ChronoTime>(System::ellapsedTime ( MyUnit ));
      m_status = IChronoSvc::RUNNING;
      return m_status ;
    }

IChronoSvc::ChronoStatus ChronoEntity::status | ( | ) | const`[inline]`

return the status of chrono

Definition at line 197 of file ChronoEntity.h.

    { return m_status; }

IChronoSvc::ChronoStatus ChronoEntity::stop | ( | ) |

stop the chrono

Definition at line 96 of file ChronoEntity.cpp.

    {
      if ( IChronoSvc::RUNNING != m_status ) { return m_status ; }

      // following lines could be platform dependent!

      m_delta_user    = System::userTime     ( MyUnit ) - m_start_user    ;
      m_delta_kernel  = System::kernelTime   ( MyUnit ) - m_start_kernel  ;
      m_delta_elapsed = System::ellapsedTime ( MyUnit ) - m_start_elapsed ;

      // update the counters:

      m_user     += m_delta_user    ;
      m_kernel   += m_delta_kernel  ;
      m_elapsed  += m_delta_elapsed ;

      // set new status

      m_status = IChronoSvc::STOPPED;

      return m_status ;
    }

double ChronoEntity::totalTime | ( | ) | const`[inline]`

total time

Definition at line 252 of file ChronoEntity.h.

    { return uTotalTime() + kTotalTime()  ; }

double ChronoEntity::uMaximalTime | ( | ) | const`[inline]`

maximal measurement for user time

Definition at line 222 of file ChronoEntity.h.

    { return m_user   . flagMax () ; }

double ChronoEntity::uMeanErrorTime | ( | ) | const`[inline]`

error in mean User time

Definition at line 293 of file ChronoEntity.h.

    { return m_user    . flagMeanErr () ; }

double ChronoEntity::uMeanTime | ( | ) | const`[inline]`

average User Time

Definition at line 263 of file ChronoEntity.h.

    { return m_user    . flagMean () ; }

double ChronoEntity::uMinimalTime | ( | ) | const`[inline]`

minimal measurement for user time

Definition at line 206 of file ChronoEntity.h.

    { return m_user   . flagMin () ; }

double ChronoEntity::uRMSTime | ( | ) | const`[inline]`

r.m.s User Time

Definition at line 278 of file ChronoEntity.h.

    { return m_user    . flagRMS  () ; }

double ChronoEntity::uTotalTime | ( | ) | const`[inline]`

total user time

Definition at line 237 of file ChronoEntity.h.

    { return m_user    . flag () ; }

## Member Data Documentation

IChronoSvc::ChronoTime ChronoEntity::m_delta_elapsed`[private]`

delta Elapsed time

Definition at line 178 of file ChronoEntity.h.

IChronoSvc::ChronoTime ChronoEntity::m_delta_kernel`[private]`

delta Kernel time

Definition at line 176 of file ChronoEntity.h.

IChronoSvc::ChronoTime ChronoEntity::m_delta_user`[private]`

delta user time

Definition at line 174 of file ChronoEntity.h.

StatEntity ChronoEntity::m_elapsed`[private]`

the actual storage of "elapsed" time

Definition at line 190 of file ChronoEntity.h.

StatEntity ChronoEntity::m_kernel`[private]`

the actual storage of "kernel" time

Definition at line 188 of file ChronoEntity.h.

IChronoSvc::ChronoTime ChronoEntity::m_start_elapsed`[private]`

start stamp for current measurement of Elapsed time

Definition at line 184 of file ChronoEntity.h.

IChronoSvc::ChronoTime ChronoEntity::m_start_kernel`[private]`

start stamp for current measurement of Kernel time

Definition at line 182 of file ChronoEntity.h.

IChronoSvc::ChronoTime ChronoEntity::m_start_user`[private]`

start stamp for current measurement of user time

Definition at line 180 of file ChronoEntity.h.

IChronoSvc::ChronoStatus ChronoEntity::m_status`[private]`

current status of this chrono object;

Definition at line 172 of file ChronoEntity.h.

StatEntity ChronoEntity::m_user`[private]`

the actual storage of "user" time

Definition at line 186 of file ChronoEntity.h.

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

- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiKernel/GaudiKernel/ChronoEntity.h
- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiKernel/src/Lib/ChronoEntity.cpp

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