CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Private Attributes
TimingReport Class Reference

#include <TimingReport.h>

Classes

class  Item
 

Public Types

typedef BaseEvent< std::pair
< double, double > > 
ItemObserver
 

Public Member Functions

void dump (std::ostream &co, bool active=false)
 
bool & inTicks ()
 report in ticks More...
 
const bool & isOn () const
 
Itemmake (const std::string &name)
 
Itemoperator[] (const std::string &name)
 
const Itemoperator[] (const std::string &name) const
 
void start (const std::string &name)
 
void stop (const std::string &name)
 
void switchOn (bool ion)
 switch all on More...
 
void switchOn (const std::string &name, bool ion)
 switch one ion More...
 
 ~TimingReport ()
 

Static Public Member Functions

static TimingReportcurrent ()
 

Protected Types

typedef std::map< std::string,
Item, std::less< std::string > > 
SMAP
 

Protected Member Functions

 TimingReport ()
 

Private Attributes

bool inTicks_
 
bool on
 
SMAP registry
 

Detailed Description

Definition at line 22 of file TimingReport.h.

Member Typedef Documentation

typedef BaseEvent< std::pair<double,double> > TimingReport::ItemObserver

Definition at line 24 of file TimingReport.h.

typedef std::map< std::string, Item, std::less<std::string> > TimingReport::SMAP
protected

Definition at line 63 of file TimingReport.h.

Constructor & Destructor Documentation

TimingReport::TimingReport ( )
protected

Definition at line 29 of file TimingReport.cc.

Referenced by current().

29  : on(true), inTicks_(false) {
30  //std::cout << "Creating a new Timing Report" << std::endl;
31  //std::cout <<"StopWatch bias " << PentiumTimer::bias()<<std::endl;
32  //std::cout <<"CPUWatch bias " << LinuxCPUTimer::bias()<<std::endl;
33 }
TimingReport::~TimingReport ( )

Definition at line 45 of file TimingReport.cc.

References gather_cfg::cout, dump(), and on.

45  {
46  if (!on) return;
47  dump(std::cout);
48 }
tuple cout
Definition: gather_cfg.py:121
void dump(std::ostream &co, bool active=false)
Definition: TimingReport.cc:50

Member Function Documentation

TimingReport * TimingReport::current ( )
static

Definition at line 21 of file TimingReport.cc.

References TimingReport().

Referenced by R2DTimerObserver::init(), HTimerStack::push(), TimerStack::push(), muonisolation::CaloExtractorByAssociator::~CaloExtractorByAssociator(), and muonisolation::JetExtractor::~JetExtractor().

21  {
22  static TimingReport * currentTimingReport=0;
23 
24  if (currentTimingReport==0) currentTimingReport = new TimingReport();
25  return currentTimingReport;
26 
27 }
void TimingReport::dump ( std::ostream &  co,
bool  active = false 
)

make the output sorted

Definition at line 50 of file TimingReport.cc.

References alignCSCRings::e, inTicks(), max(), AlCaHLTBitMon_ParallelJobs::p, registry, and GenTimer< PentiumTime >::ticksInSec().

Referenced by muonisolation::CaloExtractorByAssociator::~CaloExtractorByAssociator(), muonisolation::JetExtractor::~JetExtractor(), and ~TimingReport().

50  {
52  typedef std::map<std::string, Item *, std::less<std::string> > LMAP;
53  LMAP lreg;
54  {
55  SMAP::iterator p = registry.begin();
56  SMAP::iterator e = registry.end();
57  while (p!=e) {
58  if ( (*p).second.on && (!active||(*p).second.active()) )
59  lreg[(*p).first] = &(*p).second;
60  ++p;
61  }
62  }
63 
64  std::ostream co(ico.rdbuf());
65  size_t namew = 20;
66  co << "\n";
67  if (active) co << "Active ";
68  co << "Timing Report (in "
69  << (inTicks() ? "ticks" : "seconds") << ")\n" << std::endl;
70  LMAP::iterator p = lreg.begin();
71  LMAP::iterator e = lreg.end();
72  while (p!=e) { namew = std::max(namew,(*p).first.size()); ++p;}
73  p = lreg.begin();
74  while (p!=e) {
75  co.setf(std::ios::left,std::ios::adjustfield);
76  if (inTicks())
77  co << std::setiosflags(std::ios::showpoint)
78  << std::setprecision(3);
79  else
80  co << std::setiosflags(std::ios::showpoint | std::ios::fixed)
81  << std::setprecision(3);
82 
83  co << std::setw(namew) << (*p).first.c_str() << " ";
84  co.setf(std::ios::right,std::ios::adjustfield);
85  co << std::setw(10) << (*(*p).second).counter << " ";
86  co << std::setw(10)
87  << (inTicks() ? (*(*p).second).realticks()
88  : (*(*p).second).realsec() ) << " (real)";
89 #ifdef __linux__
90  co << " " << std::setw(10)
91  << (inTicks() ? 1./PentiumTimer::ticksInSec() : 1.)*(*(*p).second).cpusec() << " (cpu)";
92 #endif
93  co << std::endl;
94  ++p;
95  }
96  co << "\n" << std::endl;
97 }
bool & inTicks()
report in ticks
Definition: TimingReport.h:74
static double ticksInSec()
Definition: GenTimer.h:83
U second(std::pair< T, U > const &p)
const T & max(const T &a, const T &b)
bool& TimingReport::inTicks ( )
inline

report in ticks

Definition at line 74 of file TimingReport.h.

References inTicks_.

Referenced by dump().

74 { return inTicks_;}
const bool& TimingReport::isOn ( ) const
inline

Definition at line 107 of file TimingReport.h.

References on.

107 { return on;}
Item& TimingReport::make ( const std::string &  name)
inline

Definition at line 103 of file TimingReport.h.

References mergeVDriftHistosByStation::name, on, and registry.

Referenced by operator[]().

103  {
104  return registry[name].switchOn(on);
105  }
Item& TimingReport::operator[] ( const std::string &  name)
inline

Definition at line 91 of file TimingReport.h.

References make(), AlCaHLTBitMon_ParallelJobs::p, and registry.

91  {
92  SMAP::iterator p = registry.find(name);
93  if (p!=registry.end()) return (*p).second;
94  return make(name);
95  }
Item & make(const std::string &name)
Definition: TimingReport.h:103
const Item& TimingReport::operator[] ( const std::string &  name) const
inline

Definition at line 97 of file TimingReport.h.

References AlCaHLTBitMon_ParallelJobs::p, and registry.

97  {
98  SMAP::const_iterator p = registry.find(name);
99  if (p!=registry.end()) return (*p).second;
100  return const_cast<TimingReport*>(this)->make(name);
101  }
void TimingReport::start ( const std::string &  name)
inline

Definition at line 84 of file TimingReport.h.

References mergeVDriftHistosByStation::name, on, and registry.

84  {
85  if(on) registry[name].start();
86  }
void TimingReport::stop ( const std::string &  name)
inline

Definition at line 87 of file TimingReport.h.

References mergeVDriftHistosByStation::name, on, and registry.

87  {
88  if (on) registry[name].stop();
89  }
void TimingReport::switchOn ( bool  ion)

switch all on

Definition at line 35 of file TimingReport.cc.

References alignCSCRings::e, on, AlCaHLTBitMon_ParallelJobs::p, and registry.

35  {
36  if (on==ion) return;
37  on = ion;
38  //std::cout << "switching Timing Report "
39  // << (on ? "on" : "off") << std::endl;
40  SMAP::iterator p = registry.begin();
41  SMAP::iterator e = registry.end();
42  for (;p!=e; ++p) (*p).second.switchOn(on);
43 }
void TimingReport::switchOn ( const std::string &  name,
bool  ion 
)
inline

switch one ion

Definition at line 80 of file TimingReport.h.

References mergeVDriftHistosByStation::name, and registry.

80  {
81  registry[name].switchOn(ion);
82  }

Member Data Documentation

bool TimingReport::inTicks_
private

Definition at line 112 of file TimingReport.h.

Referenced by inTicks().

bool TimingReport::on
private

Definition at line 111 of file TimingReport.h.

Referenced by isOn(), make(), start(), stop(), switchOn(), and ~TimingReport().

SMAP TimingReport::registry
private

Definition at line 113 of file TimingReport.h.

Referenced by dump(), make(), operator[](), start(), stop(), and switchOn().