CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Private Attributes

TimingReport Class Reference

#include <TimingReport.h>

List of all members.

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
const bool & isOn () 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 (bool ion)
 switch all on
void switchOn (const std::string &name, bool ion)
 switch one ion
 ~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().

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

Definition at line 45 of file TimingReport.cc.

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

                            {  
    if (!on) return;
    dump(std::cout);
}

Member Function Documentation

TimingReport * TimingReport::current ( ) [static]

Definition at line 21 of file TimingReport.cc.

References TimingReport().

Referenced by TimerStack::push(), and HTimerStack::push().

                                     {
  static TimingReport * currentTimingReport=0;

  if (currentTimingReport==0) currentTimingReport = new TimingReport();
  return currentTimingReport;

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

make the output sorted

Definition at line 50 of file TimingReport.cc.

References cmsDriverOptions::counter, inTicks(), max(), L1TEmulatorMonitor_cff::p, registry, and GenTimer< PentiumTime >::ticksInSec().

Referenced by ~TimingReport().

                                                     {  
  typedef std::map<std::string, Item *, std::less<std::string> > LMAP;
  LMAP lreg;
  {
    SMAP::iterator p = registry.begin();
    SMAP::iterator e = registry.end();
    while (p!=e) { 
      if ( (*p).second.on && (!active||(*p).second.active()) )
        lreg[(*p).first] = &(*p).second; 
      ++p;
    }
  }

  std::ostream co(ico.rdbuf());
  size_t namew = 20;
  co << "\n";
  if (active) co << "Active ";
  co << "Timing Report  (in "
     << (inTicks() ? "ticks" : "seconds") << ")\n" << std::endl;
  LMAP::iterator p = lreg.begin();
  LMAP::iterator e = lreg.end();
  while (p!=e) { namew = std::max(namew,(*p).first.size()); ++p;}
  p = lreg.begin();
  while (p!=e) { 
    co.setf(std::ios::left,std::ios::adjustfield);
    if (inTicks())
      co << std::setiosflags(std::ios::showpoint)
         << std::setprecision(3);
    else
      co << std::setiosflags(std::ios::showpoint | std::ios::fixed)
         << std::setprecision(3);

    co << std::setw(namew) << (*p).first.c_str() << " "; 
    co.setf(std::ios::right,std::ios::adjustfield);
    co << std::setw(10) << (*(*p).second).counter << "   "; 
    co << std::setw(10) 
       <<  (inTicks() ? (*(*p).second).realticks() 
            : (*(*p).second).realsec() ) << " (real)"; 
#ifdef __linux__
    co << "   " << std::setw(10)
       << (inTicks() ? 1./PentiumTimer::ticksInSec() : 1.)*(*(*p).second).cpusec() << " (cpu)"; 
#endif
    co << std::endl;
    ++p;
  }
  co << "\n" << std::endl;
}
bool& TimingReport::inTicks ( ) [inline]

report in ticks

Definition at line 74 of file TimingReport.h.

References inTicks_.

Referenced by dump().

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

Definition at line 107 of file TimingReport.h.

References on.

{ 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[]().

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

Definition at line 91 of file TimingReport.h.

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

                                           {
    SMAP::iterator p = registry.find(name);
    if (p!=registry.end()) return (*p).second;
    return make(name);
  }
const Item& TimingReport::operator[] ( const std::string &  name) const [inline]

Definition at line 97 of file TimingReport.h.

References L1TEmulatorMonitor_cff::p, and registry.

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

Definition at line 84 of file TimingReport.h.

References mergeVDriftHistosByStation::name, on, and registry.

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

Definition at line 87 of file TimingReport.h.

References mergeVDriftHistosByStation::name, on, and registry.

                                   {
    if (on) registry[name].stop();
  }
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.

                                                 {
    registry[name].switchOn(ion);
  }
void TimingReport::switchOn ( bool  ion)

switch all on

Definition at line 35 of file TimingReport.cc.

References on, L1TEmulatorMonitor_cff::p, and registry.

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

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

Definition at line 113 of file TimingReport.h.

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