Belle II Software development
ModuleStatistics.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <framework/core/ModuleStatistics.h>
10
11using namespace Belle2;
12
13void ModuleStatistics::csv_header(std::ostream& output) const
14{
15 output << "name";
16 for (auto resource : {"time", "memory"}) {
17 for (auto type : {"init", "begin_run", "event", "end_run", "term", "total"}) {
18 output << "," << resource << " " << type;
19 }
20 output << "," << resource << " mean" << "," << resource << " stddev";
21 }
22 output << std::endl;
23}
24
25void ModuleStatistics::csv(std::ostream& output) const
26{
27 output << m_name;
28
29 for (EStatisticCounters type = c_Init; type <= c_Total; type = EStatisticCounters(type + 1)) {
30 output << "," << m_stats[type].getSum<0>();
31 }
32 output << "," << m_stats[c_Event].getMean<0>() << "," << m_stats[c_Event].getStddev<0>();
33
34 for (EStatisticCounters type = c_Init; type <= c_Total; type = EStatisticCounters(type + 1)) {
35 output << "," << m_stats[type].getSum<1>();
36 }
37 output << "," << m_stats[c_Event].getMean<1>() << "," << m_stats[c_Event].getStddev<1>();
38
39 output << std::endl;
40}
value_type getMean(int i) const
Return the mean for parameter i.
Definition: CalcMeanCov.h:122
value_type getSum(int i) const
Return the weighted sum values for parameter i.
Definition: CalcMeanCov.h:141
void csv(std::ostream &output) const
write data to the given stream in csv format
EStatisticCounters
Enum to define all counter types.
@ c_Init
Counting time/calls in initialize()
@ c_Event
Counting time/calls in event()
@ c_Total
Sum of the above.
CalcMeanCov< 2, value_type > m_stats[c_Total+1]
array with mean/covariance for all counters
void csv_header(std::ostream &output) const
write csv header to the given stream
std::string m_name
name of module
Abstract base class for different kinds of events.