CMS 3D CMS Logo

TimingReport Class Reference

#include <Utilities/Timing/interface/TimingReport.h>

List of all members.

Public Types

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

Public Member Functions

void dump (std::ostream &co, bool active=false)
boolinTicks ()
 report in ticks
const boolisOn () const
Itemmake (const std::string &name)
const Itemoperator[] (const std::string &name) const
Itemoperator[] (const std::string &name)
void start (const std::string &name)
void stop (const std::string &name)
void switchOn (const std::string &name, bool ion)
 switch one ion
void switchOn (bool ion)
 switch all on
 ~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

Classes

class  Item


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().

00029                            : on(true), inTicks_(false) {
00030     //std::cout << "Creating a new Timing Report" << std::endl;    
00031     //std::cout <<"StopWatch bias " << PentiumTimer::bias()<<std::endl;
00032     //std::cout <<"CPUWatch bias " << LinuxCPUTimer::bias()<<std::endl;
00033 }

TimingReport::~TimingReport (  ) 

Definition at line 45 of file TimingReport.cc.

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

00045                             {  
00046     if (!on) return;
00047     dump(std::cout);
00048 }


Member Function Documentation

TimingReport * TimingReport::current ( void   )  [static]

Definition at line 21 of file TimingReport.cc.

References TimingReport().

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

00021                                      {
00022   static TimingReport * currentTimingReport=0;
00023 
00024   if (currentTimingReport==0) currentTimingReport = new TimingReport();
00025   return currentTimingReport;
00026 
00027 }

void TimingReport::dump ( std::ostream &  co,
bool  active = false 
)

make the output sorted

Definition at line 50 of file TimingReport.cc.

References counter(), e, lat::endl(), inTicks(), max, p, and registry.

Referenced by KalmanAlignmentAlgorithm::terminate(), AlCaPi0BasicClusterRecHitsProducer::~AlCaPi0BasicClusterRecHitsProducer(), AlCaPi0RecHitsProducer::~AlCaPi0RecHitsProducer(), muonisolation::CaloExtractorByAssociator::~CaloExtractorByAssociator(), muonisolation::JetExtractor::~JetExtractor(), and ~TimingReport().

00050                                                      {  
00052   typedef std::map<std::string, Item *, std::less<std::string> > LMAP;
00053   LMAP lreg;
00054   {
00055     SMAP::iterator p = registry.begin();
00056     SMAP::iterator e = registry.end();
00057     while (p!=e) { 
00058       if ( (*p).second.on && (!active||(*p).second.active()) )
00059         lreg[(*p).first] = &(*p).second; 
00060       ++p;
00061     }
00062   }
00063 
00064   std::ostream co(ico.rdbuf());
00065   size_t namew = 20;
00066   co << "\n";
00067   if (active) co << "Active ";
00068   co << "Timing Report  (in "
00069      << (inTicks() ? "ticks" : "seconds") << ")\n" << std::endl;
00070   LMAP::iterator p = lreg.begin();
00071   LMAP::iterator e = lreg.end();
00072   while (p!=e) { namew = std::max(namew,(*p).first.size()); ++p;}
00073   p = lreg.begin();
00074   while (p!=e) { 
00075     co.setf(std::ios::left,std::ios::adjustfield);
00076     if (inTicks())
00077       co << std::setiosflags(std::ios::showpoint)
00078          << std::setprecision(3);
00079     else
00080       co << std::setiosflags(std::ios::showpoint | std::ios::fixed)
00081          << std::setprecision(3);
00082 
00083     co << std::setw(namew) << (*p).first.c_str() << " "; 
00084     co.setf(std::ios::right,std::ios::adjustfield);
00085     co << std::setw(10) << (*(*p).second).counter << "   "; 
00086     co << std::setw(10) 
00087        <<  (inTicks() ? (*(*p).second).realticks() 
00088             : (*(*p).second).realsec() ) << " (real)"; 
00089 #ifdef __linux__
00090     co << "   " << std::setw(10)
00091        << (inTicks() ? 1./PentiumTimer::ticksInSec() : 1.)*(*(*p).second).cpusec() << " (cpu)"; 
00092 #endif
00093     co << std::endl;
00094     ++p;
00095   }
00096   co << "\n" << std::endl;
00097 }

bool& TimingReport::inTicks (  )  [inline]

report in ticks

Definition at line 74 of file TimingReport.h.

References inTicks_.

Referenced by dump().

00074 { return inTicks_;}

const bool& TimingReport::isOn (  )  const [inline]

Definition at line 107 of file TimingReport.h.

References on.

00107 { return on;} 

Item& TimingReport::make ( const std::string &  name  )  [inline]

Definition at line 103 of file TimingReport.h.

References on, and registry.

Referenced by operator[]().

00103                                      {
00104     return registry[name].switchOn(on);
00105   }

const Item& TimingReport::operator[] ( const std::string &  name  )  const [inline]

Definition at line 97 of file TimingReport.h.

References p, and registry.

00097                                                        {
00098     SMAP::const_iterator p = registry.find(name);
00099     if (p!=registry.end()) return (*p).second;
00100     return const_cast<TimingReport*>(this)->make(name);
00101   }

Item& TimingReport::operator[] ( const std::string &  name  )  [inline]

Definition at line 91 of file TimingReport.h.

References make(), p, and registry.

00091                                            {
00092     SMAP::iterator p = registry.find(name);
00093     if (p!=registry.end()) return (*p).second;
00094     return make(name);
00095   }

void TimingReport::start ( const std::string &  name  )  [inline]

Definition at line 84 of file TimingReport.h.

References on, and registry.

00084                                     {
00085     if(on) registry[name].start();
00086   }

void TimingReport::stop ( const std::string &  name  )  [inline]

Definition at line 87 of file TimingReport.h.

References on, and registry.

00087                                    {
00088     if (on) registry[name].stop();
00089   }

void TimingReport::switchOn ( const std::string &  name,
bool  ion 
) [inline]

switch one ion

Definition at line 80 of file TimingReport.h.

References registry.

00080                                                  {
00081     registry[name].switchOn(ion);
00082   }

void TimingReport::switchOn ( bool  ion  ) 

switch all on

Definition at line 35 of file TimingReport.cc.

References e, on, p, and registry.

00035                                     {
00036     if (on==ion) return;
00037     on = ion;
00038     //std::cout << "switching Timing Report " 
00039     //        << (on ? "on" : "off") << std::endl;
00040   SMAP::iterator p = registry.begin();
00041   SMAP::iterator e = registry.end();
00042   for (;p!=e; ++p) (*p).second.switchOn(on);
00043 }


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().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:33:28 2009 for CMSSW by  doxygen 1.5.4