test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Timer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Timer
4 // Class: Timer
5 //
14 //
15 // Original Author: Christos Leonidopoulos
16 // Created: Mon Jul 10 14:13:58 CEST 2006
17 //
18 //
19 
20 
23 
24 #include <iostream>
25 
26 using edm::ParameterSet;
27 using edm::Service;
29 //
30 using edm::ModuleTime;
31 using edm::EventTime;
32 
33 using std::string;
34 
35 Timer::Timer(const ParameterSet& iConfig)
36 {
37  // produces<EventTime>("Timing");
38  produces<EventTime>();
39 
40  // whether to include timing info about Timer module (default: false)
41  includeSelf = iConfig.getUntrackedParameter<bool>("includeSelf", false);
42 
43  timing.reset();
44 
45  // attach method to Timing service's "new measurement" signal
47  time->newMeasurementSignal.connect(boost::bind(boost::mem_fn(&Timer::newTimingMeasurement), this, _1, _2) );
48 
49  self_module_name = string(iConfig.getParameter<string>("@module_type"));
50 }
51 
53 {
54  using namespace std;
55 
56  if(!includeSelf){
57  string longLine("==========================================================");
58  cout << longLine << endl;
59  cout << " Timer Info:\n";
60  cout << " Timer module was excluded from time measurements\n";
61  cout << " (to include, set 'bool includeSelf = true' in .cfg file)\n";
62  cout << longLine << endl << endl;
63  }
64 
65 }
66 
68  // # Make sure to enable the "TimerService" service at your top-level cfg!
69  // # by including something like the following:
70  // # service = TimerService {
71  // # untracked bool useCPUtime = true // set to false for wall-clock-time
72  // # }
73  // # This EDProducer is the module that stores in the Event the timing info
75  desc.addUntracked<bool>("includeSelf",false);
76  descriptions.add("timer", desc);
77 }
78 
79 // fwk calls this method when new module measurement arrives
80 void Timer::newTimingMeasurement(const ModuleDescription& iMod, double iTime)
81 {
82  // check if module name corresponds to "this" and skip if needed
83  if(!includeSelf && iMod.moduleName() == self_module_name)
84  return;
85 
86  // new measurement; add to private member
87  ModuleTime newModuleTime(iMod.moduleLabel(), iTime);
88  timing.addModuleTime(newModuleTime);
89 }
90 
91 
92 //
93 // member functions
94 //
95 
96 // ------------ method called to produce the data ------------
97 void
99 {
100  std::auto_ptr<EventTime> out(new EventTime(timing));
101  // reset data so that we can start from scratch for next event
102  timing.reset();
103  //
104  iEvent.put(out);
105 }
106 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Timer(const edm::ParameterSet &)
Definition: Timer.cc:35
~Timer()
Definition: Timer.cc:52
std::string const & moduleName() const
std::string const & moduleLabel() const
void addModuleTime(const ModuleTime &m)
Definition: ModuleTiming.h:58
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: Timer.cc:67
std::string self_module_name
Definition: Timer.h:64
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
void newTimingMeasurement(const edm::ModuleDescription &iMod, double iTime)
Definition: Timer.cc:80
tuple out
Definition: dbtoconf.py:99
edm::EventTime timing
Definition: Timer.h:59
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual void produce(edm::Event &, const edm::EventSetup &)
Definition: Timer.cc:98
sigc::signal< void, const edm::ModuleDescription &, double > newMeasurementSignal
Definition: TimerService.h:91
tuple cout
Definition: gather_cfg.py:121
bool includeSelf
Definition: Timer.h:61