Belle II Software light-2406-ragdoll
ModuleStatistics Class Reference

Keep track of time and memory consumption during processing. More...

#include <ModuleStatistics.h>

Collaboration diagram for ModuleStatistics:

Public Types

enum  EStatisticCounters {
  c_Init ,
  c_BeginRun ,
  c_Event ,
  c_EndRun ,
  c_Term ,
  c_Total
}
 Enum to define all counter types. More...
 
typedef double value_type
 type of float variable to use for calculations and storage
 

Public Member Functions

 ModuleStatistics (const std::string &name="")
 Construct with a given name.
 
void add (EStatisticCounters type, value_type time, value_type memory)
 Add a time and memory measurment to the counter of a given type.
 
void update (const ModuleStatistics &other)
 Add statistics for each category.
 
void setName (const std::string &name)
 Set the name of the module for display.
 
void setIndex (int index)
 Set the index of the module when displaying statistics.
 
const std::string & getName () const
 Return the previously set name.
 
int getIndex () const
 Return the index.
 
value_type getCalls (EStatisticCounters type=c_Total) const
 return the number of calls for a given counter type
 
value_type getTimeSum (EStatisticCounters type=c_Total) const
 return the sum of all execution times for a given counter
 
value_type getTimeMean (EStatisticCounters type=c_Total) const
 return the mean execution time for a given counter
 
value_type getTimeStddev (EStatisticCounters type=c_Total) const
 return the stddev of the execution times for a given counter
 
value_type getMemorySum (EStatisticCounters type=c_Total) const
 return the total used memory for a given counter
 
value_type getMemoryMean (EStatisticCounters type=c_Total) const
 return the average memory change per call
 
value_type getMemoryStddev (EStatisticCounters type=c_Total) const
 return the stddev of the memory consumption changes per call
 
value_type getTimeMemoryCorrelation (EStatisticCounters type=c_Total) const
 return the pearson correlation coefficient between execution times and memory consumption changes
 
bool operator== (const ModuleStatistics &other) const
 Check if name is identical.
 
bool operator!= (const ModuleStatistics &other) const
 inequality.
 
void clear ()
 Clear all statistics.
 

Private Attributes

int m_index
 display index of the module
 
std::string m_name
 name of module
 
CalcMeanCov< 2, value_typem_stats [c_Total+1]
 array with mean/covariance for all counters
 

Detailed Description

Keep track of time and memory consumption during processing.

This class offers a counter for time and memory consumption for all processing steps (initialize, beginRun, event, endRun, terminate and total). It will automatically calculate a running mean, stddev and correlation factor between time and memory consumption.

Definition at line 26 of file ModuleStatistics.h.

Member Typedef Documentation

◆ value_type

typedef double value_type

type of float variable to use for calculations and storage

Definition at line 45 of file ModuleStatistics.h.

Member Enumeration Documentation

◆ EStatisticCounters

Enum to define all counter types.

Enumerator
c_Init 

Counting time/calls in initialize()

c_BeginRun 

Counting time/calls in beginRun()

c_Event 

Counting time/calls in event()

c_EndRun 

Counting time/calls in endRun()

c_Term 

Counting time/calls in terminate()

c_Total 

Sum of the above.

Definition at line 29 of file ModuleStatistics.h.

29 {
31 c_Init,
35 c_Event,
39 c_Term,
42 };
@ c_Init
Counting time/calls in initialize()
@ c_EndRun
Counting time/calls in endRun()
@ c_Term
Counting time/calls in terminate()
@ c_BeginRun
Counting time/calls in beginRun()
@ c_Event
Counting time/calls in event()
@ c_Total
Sum of the above.

Constructor & Destructor Documentation

◆ ModuleStatistics()

ModuleStatistics ( const std::string &  name = "")
inlineexplicit

Construct with a given name.

Definition at line 48 of file ModuleStatistics.h.

48: m_index(0), m_name(name) {}
int m_index
display index of the module
std::string m_name
name of module

Member Function Documentation

◆ add()

void add ( EStatisticCounters  type,
value_type  time,
value_type  memory 
)
inline

Add a time and memory measurment to the counter of a given type.

Parameters
typeType of counter to add the value to
timetime used during execution
memorymemory size change during execution

Definition at line 55 of file ModuleStatistics.h.

56 {
57 m_stats[type].add(time, memory);
58 if (type != c_Total)
59 m_stats[c_Total].add(time, memory);
60 }
void add(T... values)
Update mean and covariance by adding a new entry.
Definition: CalcMeanCov.h:71
CalcMeanCov< 2, value_type > m_stats[c_Total+1]
array with mean/covariance for all counters

◆ clear()

void clear ( )
inline

Clear all statistics.

Definition at line 129 of file ModuleStatistics.h.

130 {
131 for (auto& stat : m_stats) stat.clear();
132 }

◆ getCalls()

value_type getCalls ( EStatisticCounters  type = c_Total) const
inline

return the number of calls for a given counter type

Definition at line 81 of file ModuleStatistics.h.

82 {
83 return m_stats[type].getEntries();
84 }
value_type getEntries() const
Return the number of entries.
Definition: CalcMeanCov.h:120

◆ getIndex()

int getIndex ( ) const
inline

Return the index.

Definition at line 78 of file ModuleStatistics.h.

78{ return m_index; }

◆ getMemoryMean()

value_type getMemoryMean ( EStatisticCounters  type = c_Total) const
inline

return the average memory change per call

Definition at line 107 of file ModuleStatistics.h.

108 {
109 return m_stats[type].getMean<1>();
110 }
value_type getMean(int i) const
Return the mean for parameter i.
Definition: CalcMeanCov.h:122

◆ getMemoryStddev()

value_type getMemoryStddev ( EStatisticCounters  type = c_Total) const
inline

return the stddev of the memory consumption changes per call

Definition at line 112 of file ModuleStatistics.h.

113 {
114 return m_stats[type].getStddev<1>();
115 }
value_type getStddev(int i) const
Return the standard deviation for parameter i.
Definition: CalcMeanCov.h:139

◆ getMemorySum()

value_type getMemorySum ( EStatisticCounters  type = c_Total) const
inline

return the total used memory for a given counter

Definition at line 102 of file ModuleStatistics.h.

103 {
104 return m_stats[type].getSum<1>();
105 }
value_type getSum(int i) const
Return the weighted sum values for parameter i.
Definition: CalcMeanCov.h:141

◆ getName()

const std::string & getName ( ) const
inline

Return the previously set name.

Definition at line 76 of file ModuleStatistics.h.

76{ return m_name; }

◆ getTimeMean()

value_type getTimeMean ( EStatisticCounters  type = c_Total) const
inline

return the mean execution time for a given counter

Definition at line 92 of file ModuleStatistics.h.

93 {
94 return m_stats[type].getMean<0>();
95 }

◆ getTimeMemoryCorrelation()

value_type getTimeMemoryCorrelation ( EStatisticCounters  type = c_Total) const
inline

return the pearson correlation coefficient between execution times and memory consumption changes

Definition at line 118 of file ModuleStatistics.h.

119 {
120 return m_stats[type].getCorrelation<0, 1>();
121 }
value_type getCorrelation(int i, int j) const
Return the correlation coefficient between parameters i and j.
Definition: CalcMeanCov.h:130

◆ getTimeStddev()

value_type getTimeStddev ( EStatisticCounters  type = c_Total) const
inline

return the stddev of the execution times for a given counter

Definition at line 97 of file ModuleStatistics.h.

98 {
99 return m_stats[type].getStddev<0>();
100 }

◆ getTimeSum()

value_type getTimeSum ( EStatisticCounters  type = c_Total) const
inline

return the sum of all execution times for a given counter

Definition at line 87 of file ModuleStatistics.h.

88 {
89 return m_stats[type].getSum<0>();
90 }

◆ operator!=()

bool operator!= ( const ModuleStatistics other) const
inline

inequality.

Definition at line 126 of file ModuleStatistics.h.

126{ return !(*this == other); }

◆ operator==()

bool operator== ( const ModuleStatistics other) const
inline

Check if name is identical.

Definition at line 124 of file ModuleStatistics.h.

124{ return m_name == other.m_name; }

◆ setIndex()

void setIndex ( int  index)
inline

Set the index of the module when displaying statistics.

Definition at line 73 of file ModuleStatistics.h.

73{ m_index = index; }

◆ setName()

void setName ( const std::string &  name)
inline

Set the name of the module for display.

Definition at line 71 of file ModuleStatistics.h.

71{ m_name = name; }

◆ update()

void update ( const ModuleStatistics other)
inline

Add statistics for each category.

Definition at line 63 of file ModuleStatistics.h.

64 {
65 for (int i = c_Init; i <= c_Total; i++) {
66 m_stats[i].add(other.m_stats[i]);
67 }
68 }

Member Data Documentation

◆ m_index

int m_index
private

display index of the module

Definition at line 135 of file ModuleStatistics.h.

◆ m_name

std::string m_name
private

name of module

Definition at line 137 of file ModuleStatistics.h.

◆ m_stats

CalcMeanCov<2, value_type> m_stats[c_Total+1]
private

array with mean/covariance for all counters

Definition at line 139 of file ModuleStatistics.h.


The documentation for this class was generated from the following file: