9 #include "cetlib/cpu_timer.h" 17 using std::setprecision;
22 struct SummaryCounts {
28 struct TriggerCounts {
29 std::string path_name{};
36 struct EndPathCounts {
38 std::size_t success{};
42 struct WorkerInPathCounts {
43 std::string moduleLabel{};
44 std::size_t visited{};
51 std::size_t visited{};
58 using WorkersInPath = std::vector<art::WorkerInPath>;
59 using WorkersInPathCounts = std::vector<WorkerInPathCounts>;
62 workersInPathTriggerReport(
art::PathID const path_id,
63 WorkersInPathCounts
const& workersInPathCounts)
65 for (
auto const& wip_counts : workersInPathCounts) {
69 << setw(10) << wip_counts.passed <<
" " <<
std::right << setw(10)
70 << wip_counts.failed <<
" " <<
std::right << setw(10)
71 << wip_counts.except <<
" " << wip_counts.moduleLabel;
76 workersInEndPathTriggerReport(WorkersInPathCounts
const& workersInPathCounts)
78 for (
auto const& wip_counts : workersInPathCounts) {
80 <<
"TrigReport " <<
std::right << setw(10) << wip_counts.visited <<
" " 82 << setw(10) << wip_counts.except <<
" " << wip_counts.moduleLabel;
90 bool const wantSummary,
91 cet::cpu_timer
const& jobTimer)
106 bool const wantSummary)
110 auto observers_enabled = !epis[ScheduleID::first()].paths().empty();
112 SummaryCounts total_counts{};
113 for (
auto const& tpi : tpis) {
114 total_counts.total += tpi.totalEvents();
115 total_counts.passed += tpi.passedEvents();
116 total_counts.failed += tpi.failedEvents();
120 LogPrint(
"ArtSummary") <<
"TrigReport " 121 <<
"---------- Event summary -------------";
122 LogPrint(
"ArtSummary") <<
"TrigReport" 123 <<
" Events total = " << total_counts.total
124 <<
" passed = " << total_counts.passed
125 <<
" failed = " << total_counts.failed;
129 LogPrint(
"ArtSummary") <<
"TrigReport " 130 <<
"---------- Trigger-path summary ------------";
139 std::map<PathID, TriggerCounts> counts_per_path{};
140 for (
auto const& tpi : tpis) {
141 for (
auto const& path : tpi.paths()) {
142 auto&
counts = counts_per_path[path.pathID()];
143 counts.path_name = path.name();
144 counts.run += path.timesRun();
145 counts.passed += path.timesPassed();
146 counts.failed += path.timesFailed();
147 counts.except += path.timesExcept();
150 for (
auto const& [pathID,
counts] : counts_per_path) {
160 LogPrint(
"ArtSummary") <<
"TrigReport " 161 <<
"---------- End-path summary ---------";
162 LogPrint(
"ArtSummary") <<
"TrigReport" 167 if (observers_enabled) {
168 EndPathCounts epCounts{};
169 for (
auto const& epi : epis) {
170 for (
auto const& path : epi.paths()) {
171 epCounts.run += path.timesRun();
172 epCounts.success += path.timesPassed();
173 epCounts.except += path.timesExcept();
177 <<
"TrigReport " <<
std::right << setw(10) << epCounts.run <<
" " 179 << setw(10) << epCounts.except;
182 std::map<PathSpec, WorkersInPathCounts> counts_per_worker_in_path;
183 for (
auto const& tpi : tpis) {
184 for (
auto const& path : tpi.paths()) {
185 auto& counts_per_worker = counts_per_worker_in_path[path.pathSpec()];
186 if (counts_per_worker.empty() && !path.workersInPath().empty()) {
187 counts_per_worker.resize(path.workersInPath().size());
190 for (
auto const& workerInPath : path.workersInPath()) {
191 auto const* worker = workerInPath.getWorker();
192 auto&
counts = counts_per_worker[i];
193 if (
counts.moduleLabel.empty()) {
194 counts.moduleLabel = worker->description().moduleLabel();
196 counts.visited += workerInPath.timesVisited();
197 counts.passed += workerInPath.timesPassed();
198 counts.failed += workerInPath.timesFailed();
199 counts.except += workerInPath.timesExcept();
204 for (
auto const& [
path_spec, worker_in_path_counts] :
205 counts_per_worker_in_path) {
209 <<
"---------- Modules in path: " <<
path_spec.
name <<
" ------------";
211 <<
"TrigReport " <<
std::right << setw(10) <<
"Path ID" 223 WorkersInPathCounts endPathWIPCounts;
224 for (
auto const& epi : epis) {
225 for (
auto const& path : epi.paths()) {
226 if (endPathWIPCounts.empty() && !path.workersInPath().empty()) {
227 endPathWIPCounts.resize(path.workersInPath().size());
230 for (
auto const& workerInPath : path.workersInPath()) {
231 auto const* worker = workerInPath.getWorker();
232 auto&
counts = endPathWIPCounts[i];
233 if (
counts.moduleLabel.empty()) {
234 counts.moduleLabel = worker->description().moduleLabel();
236 counts.visited += worker->timesRun();
237 counts.passed += worker->timesPassed();
238 counts.except += worker->timesExcept();
244 if (observers_enabled) {
246 LogPrint(
"ArtSummary") <<
"TrigReport " 247 <<
"---------- Modules in End-path ----------";
248 LogPrint(
"ArtSummary") <<
"TrigReport" 254 workersInEndPathTriggerReport(endPathWIPCounts);
261 LogPrint(
"ArtSummary") <<
"TrigReport " 262 <<
"---------- Module summary ------------";
271 std::map<std::string, ModuleCounts> counts_per_module;
272 auto update_counts = [&counts_per_module](
auto const& pathInfos) {
273 for (
auto const&
pi : pathInfos) {
274 for (
auto const& [module_label, module_counts] :
pi.workers()) {
275 auto&
counts = counts_per_module[module_label];
276 counts.visited += module_counts->timesVisited();
277 counts.run += module_counts->timesRun();
278 counts.passed += module_counts->timesPassed();
279 counts.failed += module_counts->timesFailed();
280 counts.except += module_counts->timesExcept();
286 for (
auto const& [module_label, module_counts] : counts_per_module) {
288 <<
"TrigReport " <<
std::right << setw(10) << module_counts.visited
289 <<
" " <<
std::right << setw(10) << module_counts.run <<
" " 291 << setw(10) << module_counts.failed <<
" " <<
std::right << setw(10)
292 << module_counts.except <<
" " << module_label;
300 LogPrint(
"ArtSummary") <<
"TimeReport " 301 <<
"---------- Time summary [sec] -------";
302 LogPrint(
"ArtSummary") <<
"TimeReport " << setprecision(6) << fixed
303 <<
"CPU = " << timer.cpuTime()
304 <<
" Real = " << timer.realTime();
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
void triggerReport(PerScheduleContainer< PathsInfo > const &endPathInfo, PerScheduleContainer< PathsInfo > const &triggerPathsInfo, bool wantSummary)
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
void writeSummary(PathManager &pm, bool wantSummary, cet::cpu_timer const &timer)
counts_as<> counts
Number of ADC counts, represented by signed short int.
PathsInfo & triggerPathsInfo(ScheduleID)
PathsInfo & endPathInfo(ScheduleID)
void timeReport(cet::cpu_timer const &timer)
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
PathSpec path_spec(std::string const &path_spec)
MaybeLogger_< ELseverityLevel::ELsev_warning, true > LogPrint