CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ProfilerService.cc
Go to the documentation of this file.
2 
6 
7 #include <algorithm>
8 #include <limits>
9 
10 #include "valgrind/callgrind.h"
11 
13  edm::ActivityRegistry & activity) :
14 
15  m_firstEvent(pset.getUntrackedParameter<int>("firstEvent",0 )),
16  m_lastEvent(pset.getUntrackedParameter<int>("lastEvent",std::numeric_limits<int>::max())),
17  m_dumpInterval(pset.getUntrackedParameter<int>("dumpInterval",100)),
18  m_paths(pset.getUntrackedParameter<std::vector<std::string> >("paths",std::vector<std::string>() )),
19  m_excludedPaths(pset.getUntrackedParameter<std::vector<std::string> >("excludePaths",std::vector<std::string>() )),
20  m_allPaths(false),
21  m_evtCount(0),
22  m_counts(0),
23  m_doEvent(false),
24  m_active(0),
25  m_paused(false) {
26  static std::string const allPaths("ALL");
27  m_allPaths = std::find(m_paths.begin(),m_paths.end(),allPaths) != m_paths.end();
28 
29  // either FullEvent or selected path
30  static std::string const fullEvent("FullEvent");
31  if (std::find(m_paths.begin(),m_paths.end(),fullEvent) != m_paths.end())
33  else {
38  }
39 }
40 
42  dumpStat();
43 }
44 
45 #pragma GCC diagnostic push
46 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
48  // FIXME here or in client?
49  if (!doEvent()) return false;
50 
51 
52  if (m_active==0) {
53  CALLGRIND_START_INSTRUMENTATION;
55  ++m_counts;
56  }
57  // support nested start/stop
58  ++m_active;
59  return m_active==1;
60 }
61 
63  if (m_active==0) return false;
64  --m_active;
65  if (m_active==0)
66  CALLGRIND_STOP_INSTRUMENTATION;
67  return m_active==0;
68 }
69 
71  if (m_active==0) return false;
72  // FIXME report something if appens;
73  CALLGRIND_STOP_INSTRUMENTATION;
74  m_active=0;
75  return true;
76 }
77 
79  if (m_active==0) return false;
80  CALLGRIND_STOP_INSTRUMENTATION;
81  m_paused=true;
82  return true;
83 }
84 
86  if (m_active==0 || (!m_paused)) return false;
87  CALLGRIND_START_INSTRUMENTATION;
89  ++m_counts;
90  m_paused=false;
91  return true;
92 }
93 
95  CALLGRIND_DUMP_STATS;
96 }
97 #pragma GCC diagnostic pop
98 
100  ++m_evtCount;
102 }
103 
104 
106  newEvent();
107  if(m_doEvent&&m_active==0)
109  if ( (!m_doEvent) && m_active!=0) {
111  // force, a nested instrumentation may fail to close in presence of filters
113  dumpStat();
114  }
115 }
116 
118  newEvent();
119  // static std::string const fullEvent("FullEvent");
120  // if (std::find(m_paths.begin(),m_paths.end(),fullEvent) != m_paths.end())
121  if (m_allPaths)
123 }
124 
127  // force, a nested instrumentation may fail to close in presence of filters
129 }
130 
132  if (!doEvent()) return;
133  // assume less than 5-6 path to instrument or to exclude
134  if (std::find(m_excludedPaths.begin(),m_excludedPaths.end(),path) != m_excludedPaths.end()) {
136  return;
137  }
138  if (std::find(m_paths.begin(),m_paths.end(),path) == m_paths.end()) return;
141 }
142 
145  if (m_activePath==path) {
147  m_activePath.clear();
148  }
149  // do to force, a nested instrumentation may fail to close in presence of filters
150  // forceStopInstrumentation();
151 }
std::vector< std::string > m_excludedPaths
bool resumeInstrumentation()
std::vector< std::string > m_paths
void beginPath(std::string const &path)
void endPath(std::string const &path)
void watchPreProcessEvent(PreProcessEvent::slot_type const &iSlot)
std::string m_activePath
~ProfilerService()
Destructor.
void watchPostSourceEvent(PostSourceEvent::slot_type const &iSlot)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void endEventI(const edm::Event &, const edm::EventSetup &)
bool stopInstrumentation()
stop instrumentation if not active anymore; true if stopped now
void watchPostProcessEvent(PostProcessEvent::slot_type const &iSlot)
void preSourceI(edm::StreamID)
const T & max(const T &a, const T &b)
bool forceStopInstrumentation()
forced stop instrumentation independenly of activity status; true if stopped now
bool pauseInstrumentation()
bool startInstrumentation()
start instrumentation if not active. true if started now
void beginEventI(const edm::EventID &, const edm::Timestamp &)
void dumpStat() const
dump profiling information
void beginPathI(std::string const &path)
void endPathI(std::string const &path, const edm::HLTPathStatus &)
volatile std::atomic< bool > shutdown_flag false
ProfilerService(edm::ParameterSet const &pset, edm::ActivityRegistry &activity)
Standard Service Constructor.
void watchPreProcessPath(PreProcessPath::slot_type const &iSlot)
void watchPostProcessPath(PostProcessPath::slot_type const &iSlot)
bool doEvent() const
true if the current event has to be instrumented