Gaudi Framework, version v25r0

Home   Generated: Mon Feb 17 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
SequencerTimerTool Class Reference

Implements the time measurement inside a sequencer. More...

#include <SequencerTimerTool.h>

Inheritance diagram for SequencerTimerTool:
Inheritance graph
[legend]
Collaboration diagram for SequencerTimerTool:
Collaboration graph
[legend]

Public Member Functions

 SequencerTimerTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard constructor.
 
virtual ~SequencerTimerTool ()
 Destructor.
 
virtual StatusCode initialize ()
 initialize method, to compute the normalization factor
 
virtual StatusCode finalize ()
 finalize method, to print the time summary table
 
virtual int addTimer (const std::string &name)
 add a timer entry with the specified name
 
virtual void increaseIndent ()
 Increase the indentation of the name.
 
virtual void decreaseIndent ()
 Decrease the indentation of the name.
 
void start (int index)
 start the counter, i.e.
 
double stop (int index)
 stop the counter, return the elapsed time
 
double lastTime (int index)
 returns the last time
 
const std::stringname (int index)
 returns the name of the counter
 
int indexByName (const std::string &name)
 returns the index of the counter with that name, or -1
 
virtual bool globalTiming ()
 returns the flag telling that global timing is wanted
 
virtual void saveHistograms ()
 prepares and saves the timing histograms
 
- Public Member Functions inherited from ISequencerTimerTool
 DeclareInterfaceID (ISequencerTimerTool, 3, 0)
 InterfaceID.
 
virtual ~ISequencerTimerTool ()
 Destructor.
 
- Public Member Functions inherited from IAlgTool
 DeclareInterfaceID (IAlgTool, 3, 0)
 InterfaceID.
 
virtual ~IAlgTool ()
 Virtual destructor.
 
virtual const std::stringtype () const =0
 The type of an AlgTool, meaning the concrete AlgTool class.
 
virtual const IInterfaceparent () const =0
 The parent of the concrete AlgTool.
 
virtual StatusCode configure ()=0
 Configuration (from OFFLINE to CONFIGURED).
 
virtual StatusCode start ()=0
 Start (from INITIALIZED to RUNNING).
 
virtual StatusCode stop ()=0
 Stop (from RUNNING to INITIALIZED).
 
virtual StatusCode terminate ()=0
 Initialization (from CONFIGURED to OFFLINE).
 
virtual StatusCode reinitialize ()=0
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
 
virtual StatusCode restart ()=0
 Initialization (from RUNNING to RUNNING, via INITIALIZED).
 
virtual Gaudi::StateMachine::State FSMState () const =0
 Get the current state.
 
virtual StatusCode sysInitialize ()=0
 Initialization of the Tool.
 
virtual StatusCode sysStart ()=0
 Initialization of the Tool.
 
virtual StatusCode sysStop ()=0
 Initialization of the Tool.
 
virtual StatusCode sysFinalize ()=0
 Finalization of the Tool.
 
virtual StatusCode sysReinitialize ()=0
 Initialization of the Tool.
 
virtual StatusCode sysRestart ()=0
 Initialization of the Tool.
 
virtual unsigned long refCount () const =0
 Current number of reference counts.
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID.
 
virtual const std::stringname () const =0
 Retrieve the name of the instance.
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes).
 
- Public Member Functions inherited from IInterface
virtual void * i_cast (const InterfaceID &) const =0
 main cast function
 
virtual std::vector< std::stringgetInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces.
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance.
 
virtual unsigned long release ()=0
 Release Interface instance.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance.
 
virtual ~IInterface ()
 Virtual destructor.
 

Private Attributes

int m_shots
 Number of shots for CPU normalization.
 
bool m_normalised
 Is the time scaled to a nominal PIII ?
 
int m_indent
 Amount of indentation.
 
std::vector< TimerForSequencerm_timerList
 
double m_normFactor
 Factor to convert to standard CPU (1 GHz PIII)
 
double m_speedRatio
 
bool m_globalTiming
 
std::string::size_type m_headerSize
 Size of the name field.
 

Additional Inherited Members

- Public Types inherited from GaudiHistos< GaudiTool >
typedef GaudiAlg::HistoID HistoID
 the actual type for histogram identifier
 
typedef GaudiAlg::Histo1DMapID Histo1DMapID
 the actual type for (ID)->(1D histogram) mapping
 
typedef GaudiAlg::Histo1DMapTitle Histo1DMapTitle
 the actual type for title->(1D histogram) mapping
 
typedef GaudiAlg::Histo2DMapID Histo2DMapID
 the actual type for (ID)->(2D histogram) mapping
 
typedef GaudiAlg::Histo2DMapTitle Histo2DMapTitle
 the actual type for title->(2D histogram) mapping
 
typedef GaudiAlg::Histo3DMapID Histo3DMapID
 the actual type for (ID)->(3D histogram) mapping
 
typedef GaudiAlg::Histo3DMapTitle Histo3DMapTitle
 the actual type for title->(3D histogram) mapping
 
typedef GaudiAlg::Profile1DMapID Profile1DMapID
 the actual type for (ID)->(1D profile histogram) mapping
 
typedef GaudiAlg::Profile1DMapTitle Profile1DMapTitle
 the actual type for title->(1D profile histogram) mapping
 
typedef GaudiAlg::Profile2DMapID Profile2DMapID
 the actual type for (ID)->(2D profile histogram) mapping
 
typedef GaudiAlg::Profile2DMapTitle Profile2DMapTitle
 the actual type for title->(2D profile histogram) mapping
 
typedef GaudiAlg::HistoBinEdges HistoBinEdges
 Edges for variable binning.
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID.
 
typedef mpl::set1< iidext_iids
 Extra interfaces.
 
- Static Public Member Functions inherited from GaudiTool
static bool enableSummary (bool)
 enable/disable summary
 
static bool summaryEnabled ()
 is summary enabled?
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface.
 
- Protected Types inherited from GaudiCommon< AlgTool >
typedef std::map< std::string,
StatEntity
Statistics
 the actual type of general counters
 
typedef std::map< std::string,
unsigned int
Counter
 the actual type error/warning counter
 
typedef std::vector< IAlgTool * > AlgTools
 storage for active tools
 
typedef GaudiUtils::HashMap
< std::string, SmartIF
< IService > > 
Services
 storage for active services
 
- Protected Member Functions inherited from GaudiHistoTool
 GaudiHistoTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard constructor (protected)
 
virtual ~GaudiHistoTool ()
 destructor, virtual and protected
 
- Protected Attributes inherited from GaudiCommon< AlgTool >
ICounterSummarySvcm_counterSummarySvc
 a pointer to the CounterSummarySvc
 
std::vector< std::stringm_counterList
 list of counters to declare. Set by property CounterList. This can be a regular expression.
 
std::vector< std::stringm_statEntityList
 
- Static Protected Attributes inherited from GaudiCommon< AlgTool >
static const bool IgnoreRootInTES
 Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods.
 
static const bool UseRootInTES
 Simple definition to be used with the new useRootInTES argument get<TYPE> and put methods.
 

Detailed Description

Implements the time measurement inside a sequencer.

The width of the timing table column printing the algorithm name
is 30 by default. That can be changed via
@verbatim 

TimingAuditor().addTool(SequencerTimerTool, name = "TIMER") TimingAuditor().TIMER.NameSize = 50

@author Olivier Callot
@date   2004-05-19

Definition at line 27 of file SequencerTimerTool.h.

Constructor & Destructor Documentation

SequencerTimerTool::SequencerTimerTool ( const std::string type,
const std::string name,
const IInterface parent 
)

Standard constructor.

Definition at line 26 of file SequencerTimerTool.cpp.

: GaudiHistoTool ( type, name , parent )
, m_indent( 0 )
, m_normFactor( 0.001 )
{
declareInterface<ISequencerTimerTool>(this);
m_shots = 3500000 ; // 1s on 2.8GHz Xeon, gcc 3.2, -o2
declareProperty( "shots" , m_shots );
declareProperty( "Normalised" , m_normalised = false );
declareProperty( "GlobalTiming" , m_globalTiming = false );
declareProperty( "NameSize" , m_headerSize = 30,
"Number of characters to be used in algorithm name column" );
// Histograms are disabled by default in this tool.
setProperty("HistoProduce", false).ignore();
}
SequencerTimerTool::~SequencerTimerTool ( )
virtual

Destructor.

Definition at line 48 of file SequencerTimerTool.cpp.

{}

Member Function Documentation

int SequencerTimerTool::addTimer ( const std::string name)
virtual

add a timer entry with the specified name

Implements ISequencerTimerTool.

Definition at line 151 of file SequencerTimerTool.cpp.

{
std::string myName;
if ( 0 < m_indent )
{
const std::string prefix( m_indent, ' ' );
myName += prefix;
}
myName += name;
if ( myName.size() < m_headerSize )
{
const std::string space( m_headerSize - myName.size(), ' ' );
myName += space ;
}
//myName = myName.substr( 0, m_headerSize );
return m_timerList.size() - 1;
}
virtual void SequencerTimerTool::decreaseIndent ( )
inlinevirtual

Decrease the indentation of the name.

Implements ISequencerTimerTool.

Definition at line 59 of file SequencerTimerTool.h.

{
m_indent -= 2;
if ( 0 > m_indent ) m_indent = 0;
}
StatusCode SequencerTimerTool::finalize ( )
virtual

finalize method, to print the time summary table

Reimplemented from GaudiHistoTool.

Definition at line 83 of file SequencerTimerTool.cpp.

{
info() << line << endmsg
<< "This machine has a speed about "
<< format( "%6.2f", 1000.*m_speedRatio)
<< " times the speed of a 2.8 GHz Xeon.";
if ( m_normalised ) info() <<" *** All times are renormalized ***";
<< line << endmsg;
std::string lastName = "";
for ( unsigned int kk=0 ; m_timerList.size() > kk ; kk++ )
{
if ( lastName == m_timerList[kk].name() ) continue; // suppress duplicate
lastName = m_timerList[kk].name();
info() << m_timerList[kk] << endmsg;
}
info() << line << endmsg;
}
virtual bool SequencerTimerTool::globalTiming ( )
inlinevirtual

returns the flag telling that global timing is wanted

Implements ISequencerTimerTool.

Definition at line 81 of file SequencerTimerTool.h.

{ return m_globalTiming; };
virtual void SequencerTimerTool::increaseIndent ( )
inlinevirtual

Increase the indentation of the name.

Implements ISequencerTimerTool.

Definition at line 56 of file SequencerTimerTool.h.

{ m_indent += 2; }
int SequencerTimerTool::indexByName ( const std::string name)
virtual

returns the index of the counter with that name, or -1

Implements ISequencerTimerTool.

Definition at line 110 of file SequencerTimerTool.cpp.

{
std::string::size_type beg = name.find_first_not_of(" \t");
std::string::size_type end = name.find_last_not_of(" \t");
std::string temp = name.substr( beg, end-beg+1 );
for ( unsigned int kk=0 ; m_timerList.size() > kk ; kk++ ) {
beg = m_timerList[kk].name().find_first_not_of(" \t");
end = m_timerList[kk].name().find_last_not_of(" \t");
if ( m_timerList[kk].name().substr(beg,end-beg+1) == temp ) return kk;
}
return -1;
}
StatusCode SequencerTimerTool::initialize ( )
virtual

initialize method, to compute the normalization factor

Reimplemented from GaudiHistoTool.

Definition at line 54 of file SequencerTimerTool.cpp.

{
if ( sc.isFailure() ) return sc;
double sum = 0;
norm.start();
IRndmGenSvc* rsvc = svc<IRndmGenSvc>( "RndmGenSvc", true );
{ // Use dummy loop suggested by Vanya Belyaev:
gauss.initialize( rsvc , Rndm::Gauss(0.,1.0) ).ignore();
unsigned int shots = m_shots;
while( 0 < --shots ) { sum += gauss() * sum ; }
}
norm.stop();
double time = norm.lastCpu();
m_speedRatio = 1./time;
info() << "This machine has a speed about "
<< format( "%6.2f", 1000.*m_speedRatio)
<< " times the speed of a 2.8 GHz Xeon." << endmsg ;
if ( m_normalised ) {
}
return sc;
}
double SequencerTimerTool::lastTime ( int  index)
inlinevirtual

returns the last time

Implements ISequencerTimerTool.

Definition at line 72 of file SequencerTimerTool.h.

{ return m_timerList[index].lastTime(); }
const std::string& SequencerTimerTool::name ( int  index)
inlinevirtual

returns the name of the counter

Implements ISequencerTimerTool.

Definition at line 75 of file SequencerTimerTool.h.

{ return m_timerList[index].name(); }
void SequencerTimerTool::saveHistograms ( )
virtual

prepares and saves the timing histograms

Implements ISequencerTimerTool.

Definition at line 126 of file SequencerTimerTool.cpp.

{
if ( produceHistos() )
{
info() << "Saving Timing histograms" << endmsg;
const size_t bins = m_timerList.size();
AIDA::IHistogram1D* histoTime = book("ElapsedTime", 0, bins, bins);
AIDA::IHistogram1D* histoCPU = book("CPUTime", 0, bins, bins);
AIDA::IHistogram1D* histoCount = book("Count", 0, bins, bins);
TH1D* tHtime = Gaudi::Utils::Aida2ROOT::aida2root(histoTime);
TH1D* tHCPU = Gaudi::Utils::Aida2ROOT::aida2root(histoCPU);
TH1D* tHCount = Gaudi::Utils::Aida2ROOT::aida2root(histoCount);
for ( size_t kk = 0 ; bins > kk ; kk++ )
{
tHtime->Fill(tfsq.name().c_str(), tfsq.elapsedTotal());
tHCPU->Fill(tfsq.name().c_str(), tfsq.cpuTotal());
tHCount->Fill(tfsq.name().c_str(), tfsq.count());
}
}
}
void SequencerTimerTool::start ( int  index)
inlinevirtual

start the counter, i.e.

register the current time

Implements ISequencerTimerTool.

Definition at line 66 of file SequencerTimerTool.h.

{ m_timerList[index].start(); }
double SequencerTimerTool::stop ( int  index)
inlinevirtual

stop the counter, return the elapsed time

Implements ISequencerTimerTool.

Definition at line 69 of file SequencerTimerTool.h.

{ return m_timerList[index].stop(); }

Member Data Documentation

bool SequencerTimerTool::m_globalTiming
private

Definition at line 94 of file SequencerTimerTool.h.

std::string::size_type SequencerTimerTool::m_headerSize
private

Size of the name field.

Definition at line 95 of file SequencerTimerTool.h.

int SequencerTimerTool::m_indent
private

Amount of indentation.

Definition at line 90 of file SequencerTimerTool.h.

bool SequencerTimerTool::m_normalised
private

Is the time scaled to a nominal PIII ?

Definition at line 89 of file SequencerTimerTool.h.

double SequencerTimerTool::m_normFactor
private

Factor to convert to standard CPU (1 GHz PIII)

Definition at line 92 of file SequencerTimerTool.h.

int SequencerTimerTool::m_shots
private

Number of shots for CPU normalization.

Definition at line 88 of file SequencerTimerTool.h.

double SequencerTimerTool::m_speedRatio
private

Definition at line 93 of file SequencerTimerTool.h.

std::vector<TimerForSequencer> SequencerTimerTool::m_timerList
private

Definition at line 91 of file SequencerTimerTool.h.


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

Generated at Mon Feb 17 2014 14:38:10 for Gaudi Framework, version v25r0 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004