CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
Timer Class Reference

#include <HLTrigger/Timer/src/Timer.cc>

Inheritance diagram for Timer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void newTimingMeasurement (const edm::ModuleDescription &iMod, double iTime)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 Timer (const edm::ParameterSet &)
 
 ~Timer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

bool includeSelf
 
std::string self_module_name
 
edm::EventTime timing
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: EDProducer that uses the EventTime structure to store in the Event the names and processing times (per event) for all modules.

Implementation: <Notes on="" implementation>="">

Definition at line 46 of file Timer.h.

Constructor & Destructor Documentation

Timer::Timer ( const edm::ParameterSet iConfig)
explicit

Definition at line 38 of file Timer.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), includeSelf, TimerService::newMeasurementSignal, newTimingMeasurement(), edm::EventTime::reset(), self_module_name, AlCaHLTBitMon_QueryRunRegistry::string, ntuplemaker::time, and timing.

39 {
40  // produces<EventTime>("Timing");
41  produces<EventTime>();
42 
43  // whether to include timing info about Timer module (default: false)
44  includeSelf = iConfig.getUntrackedParameter<bool>("includeSelf", false);
45 
46  timing.reset();
47 
48  // attach method to Timing service's "new measurement" signal
50  time->newMeasurementSignal.connect(boost::bind(boost::mem_fn(&Timer::newTimingMeasurement), this, _1, _2) );
51 
52  self_module_name = string(iConfig.getParameter<string>("@module_type"));
53 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string self_module_name
Definition: Timer.h:64
void newTimingMeasurement(const edm::ModuleDescription &iMod, double iTime)
Definition: Timer.cc:83
edm::EventTime timing
Definition: Timer.h:59
sigc::signal< void, const edm::ModuleDescription &, double > newMeasurementSignal
Definition: TimerService.h:91
bool includeSelf
Definition: Timer.h:61
Timer::~Timer ( )

Definition at line 55 of file Timer.cc.

References gather_cfg::cout, and includeSelf.

56 {
57  using namespace std;
58 
59  if(!includeSelf){
60  string longLine("==========================================================");
61  cout << longLine << endl;
62  cout << " Timer Info:\n";
63  cout << " Timer module was excluded from time measurements\n";
64  cout << " (to include, set 'bool includeSelf = true' in .cfg file)\n";
65  cout << longLine << endl << endl;
66  }
67 
68 }
bool includeSelf
Definition: Timer.h:61

Member Function Documentation

void Timer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 70 of file Timer.cc.

References edm::ConfigurationDescriptions::add(), and edm::ParameterSetDescription::addUntracked().

70  {
71  // # Make sure to enable the "TimerService" service at your top-level cfg!
72  // # by including something like the following:
73  // # service = TimerService {
74  // # untracked bool useCPUtime = true // set to false for wall-clock-time
75  // # }
76  // # This EDProducer is the module that stores in the Event the timing info
78  desc.addUntracked<bool>("includeSelf",false);
79  descriptions.add("timer", desc);
80 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void Timer::newTimingMeasurement ( const edm::ModuleDescription iMod,
double  iTime 
)

Definition at line 83 of file Timer.cc.

References edm::EventTime::addModuleTime(), includeSelf, edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::moduleName(), self_module_name, and timing.

Referenced by Timer().

84 {
85  // check if module name corresponds to "this" and skip if needed
86  if(!includeSelf && iMod.moduleName() == self_module_name)
87  return;
88 
89  // new measurement; add to private member
90  ModuleTime newModuleTime(iMod.moduleLabel(), iTime);
91  timing.addModuleTime(newModuleTime);
92 }
std::string const & moduleName() const
std::string const & moduleLabel() const
void addModuleTime(const ModuleTime &m)
Definition: ModuleTiming.h:58
std::string self_module_name
Definition: Timer.h:64
edm::EventTime timing
Definition: Timer.h:59
bool includeSelf
Definition: Timer.h:61
void Timer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Definition at line 101 of file Timer.cc.

References eostools::move(), MillePedeFileConverter_cfg::out, edm::Event::put(), edm::EventTime::reset(), and timing.

102 {
103  std::unique_ptr<EventTime> out(new EventTime(timing));
104  // reset data so that we can start from scratch for next event
105  timing.reset();
106  //
107  iEvent.put(std::move(out));
108 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
edm::EventTime timing
Definition: Timer.h:59
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

bool Timer::includeSelf
private

Definition at line 61 of file Timer.h.

Referenced by newTimingMeasurement(), Timer(), and ~Timer().

std::string Timer::self_module_name
private

Definition at line 64 of file Timer.h.

Referenced by newTimingMeasurement(), and Timer().

edm::EventTime Timer::timing
private

Definition at line 59 of file Timer.h.

Referenced by newTimingMeasurement(), produce(), and Timer().