CMS 3D CMS Logo

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  :
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(
20  pset.getUntrackedParameter<std::vector<std::string> >("excludePaths", std::vector<std::string>())),
21  m_allPaths(false),
22  m_evtCount(0),
23  m_counts(0),
24  m_doEvent(false),
25  m_active(0),
26  m_paused(false) {
27  static std::string const allPaths("ALL");
28  m_allPaths = std::find(m_paths.begin(), m_paths.end(), allPaths) != m_paths.end();
29 
30  // either FullEvent or selected path
31  static std::string const fullEvent("FullEvent");
32  if (std::find(m_paths.begin(), m_paths.end(), fullEvent) != m_paths.end())
34  else {
39  }
40 }
41 
43 
44 #pragma GCC diagnostic push
45 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
47  // FIXME here or in client?
48  if (!doEvent())
49  return false;
50 
51  if (m_active == 0) {
52  CALLGRIND_START_INSTRUMENTATION;
53  if (m_counts % m_dumpInterval == 0)
54  dumpStat();
55  ++m_counts;
56  }
57  // support nested start/stop
58  ++m_active;
59  return m_active == 1;
60 }
61 
63  if (m_active == 0)
64  return false;
65  --m_active;
66  if (m_active == 0)
67  CALLGRIND_STOP_INSTRUMENTATION;
68  return m_active == 0;
69 }
70 
72  if (m_active == 0)
73  return false;
74  // FIXME report something if appens;
75  CALLGRIND_STOP_INSTRUMENTATION;
76  m_active = 0;
77  return true;
78 }
79 
81  if (m_active == 0)
82  return false;
83  CALLGRIND_STOP_INSTRUMENTATION;
84  m_paused = true;
85  return true;
86 }
87 
89  if (m_active == 0 || (!m_paused))
90  return false;
91  CALLGRIND_START_INSTRUMENTATION;
92  if (m_counts % m_dumpInterval == 0)
93  dumpStat();
94  ++m_counts;
95  m_paused = false;
96  return true;
97 }
98 
99 void ProfilerService::dumpStat() const { CALLGRIND_DUMP_STATS; }
100 #pragma GCC diagnostic pop
101 
103  ++m_evtCount;
105 }
106 
108  newEvent();
109  if (m_doEvent && m_active == 0)
111  if ((!m_doEvent) && m_active != 0) {
113  // force, a nested instrumentation may fail to close in presence of filters
115  dumpStat();
116  }
117 }
118 
120  newEvent();
121  // static std::string const fullEvent("FullEvent");
122  // if (std::find(m_paths.begin(),m_paths.end(),fullEvent) != m_paths.end())
123  if (m_allPaths)
125 }
126 
129  // force, a nested instrumentation may fail to close in presence of filters
131 }
132 
134  if (!doEvent())
135  return;
136  // assume less than 5-6 path to instrument or to exclude
137  if (std::find(m_excludedPaths.begin(), m_excludedPaths.end(), path) != m_excludedPaths.end()) {
139  return;
140  }
141  if (std::find(m_paths.begin(), m_paths.end(), path) == m_paths.end())
142  return;
143  m_activePath = path;
145 }
146 
149  if (m_activePath == path) {
151  m_activePath.clear();
152  }
153  // do to force, a nested instrumentation may fail to close in presence of filters
154  // forceStopInstrumentation();
155 }
ProfilerService.h
ProfilerService::stopInstrumentation
bool stopInstrumentation()
stop instrumentation if not active anymore; true if stopped now
Definition: ProfilerService.cc:62
MessageLogger.h
mutracking_dqm_sourceclient-live_cfg.allPaths
allPaths
Definition: mutracking_dqm_sourceclient-live_cfg.py:181
ProfilerService::fullEvent
void fullEvent()
Definition: ProfilerService.cc:107
funct::false
false
Definition: Factorize.h:29
ProfilerService::m_firstEvent
int m_firstEvent
Definition: ProfilerService.h:85
ProfilerService::endEventI
void endEventI(edm::StreamContext const &stream)
Definition: ProfilerService.h:67
ProfilerService::startInstrumentation
bool startInstrumentation()
start instrumentation if not active. true if started now
Definition: ProfilerService.cc:46
ProfilerService::endPath
void endPath(std::string const &path)
Definition: ProfilerService.cc:147
ProfilerService::m_active
int m_active
Definition: ProfilerService.h:96
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
ProfilerService::~ProfilerService
~ProfilerService()
Destructor.
Definition: ProfilerService.cc:42
edm::ActivityRegistry::watchPostSourceEvent
void watchPostSourceEvent(PostSourceEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:190
edm::ActivityRegistry::watchPreEvent
void watchPreEvent(PreEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:458
edm::ActivityRegistry
Definition: ActivityRegistry.h:134
ProfilerService::m_dumpInterval
int m_dumpInterval
Definition: ProfilerService.h:87
ProfilerService::beginEvent
void beginEvent()
Definition: ProfilerService.cc:119
ProfilerService::ProfilerService
ProfilerService(edm::ParameterSet const &pset, edm::ActivityRegistry &activity)
Standard Service Constructor.
Definition: ProfilerService.cc:12
ProfilerService::beginEventI
void beginEventI(edm::StreamContext const &stream)
Definition: ProfilerService.h:65
ServiceMaker.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ProfilerService::m_excludedPaths
std::vector< std::string > m_excludedPaths
Definition: ProfilerService.h:89
ProfilerService::resumeInstrumentation
bool resumeInstrumentation()
Definition: ProfilerService.cc:88
ProfilerService::m_doEvent
bool m_doEvent
Definition: ProfilerService.h:95
edm::ActivityRegistry::watchPostEvent
void watchPostEvent(PostEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:464
edm::ParameterSet
Definition: ParameterSet.h:47
ProfilerService::beginPath
void beginPath(std::string const &path)
Definition: ProfilerService.cc:133
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
ProfilerService::beginPathI
void beginPathI(edm::StreamContext const &stream, edm::PathContext const &path)
Definition: ProfilerService.h:68
ProfilerService::endPathI
void endPathI(edm::StreamContext const &stream, edm::PathContext const &path, edm::HLTPathStatus const &)
Definition: ProfilerService.h:69
ProfilerService::m_counts
int m_counts
Definition: ProfilerService.h:94
ProfilerService::pauseInstrumentation
bool pauseInstrumentation()
Definition: ProfilerService.cc:80
createfilelist.int
int
Definition: createfilelist.py:10
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
ProfilerService::m_lastEvent
int m_lastEvent
Definition: ProfilerService.h:86
edm::ActivityRegistry::watchPostPathEvent
void watchPostPathEvent(PostPathEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:476
ProfilerService::m_activePath
std::string m_activePath
Definition: ProfilerService.h:98
ProfilerService::m_evtCount
int m_evtCount
Definition: ProfilerService.h:93
ProfilerService::newEvent
void newEvent()
Definition: ProfilerService.cc:102
ProfilerService::m_paths
std::vector< std::string > m_paths
Definition: ProfilerService.h:88
std
Definition: JetResolutionObject.h:76
ProfilerService::doEvent
bool doEvent() const
true if the current event has to be instrumented
Definition: ProfilerService.h:56
ProfilerService::m_paused
bool m_paused
Definition: ProfilerService.h:97
ProfilerService::forceStopInstrumentation
bool forceStopInstrumentation()
forced stop instrumentation independenly of activity status; true if stopped now
Definition: ProfilerService.cc:71
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
ParameterSet.h
edm::ActivityRegistry::watchPrePathEvent
void watchPrePathEvent(PrePathEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:470
ProfilerService::endEvent
void endEvent()
Definition: ProfilerService.cc:127
ProfilerService::preSourceI
void preSourceI(edm::StreamID)
Definition: ProfilerService.h:63
ProfilerService::m_allPaths
bool m_allPaths
Definition: ProfilerService.h:90
ProfilerService::dumpStat
void dumpStat() const
dump profiling information
Definition: ProfilerService.cc:99
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27