Classes | Public Member Functions | Protected Attributes | List of all members
Statistics Class Reference

A class to compute statistics about quantities of interest. More...

#include <statistics.hpp>

Classes

struct  QuantityData
 

Public Member Functions

long double get_average (std::string name)
 
long double get_last (std::string name)
 
long double get_max (std::string name)
 
long double get_min (std::string name)
 
long double get_total (std::string name)
 
bool quantity_exists (std::string name)
 
void report (std::string name, int precision=2, std::ostream &output=std::cout)
 
void report_all (int precision=2, std::ostream &output=std::cout)
 
void reset (std::string name)
 
void reset_all ()
 
 Statistics ()
 
void store (std::string name, const double &value)
 
void turn_off ()
 
void turn_on ()
 
 ~Statistics ()
 

Protected Attributes

bool active
 
std::map< std::string, QuantityData > * records_of
 

Detailed Description

A class to compute statistics about quantities of interest.

Statistics stat();

The Statistics class can be used to keep track of the minimum, maximum, average of quantities of interest.

To report the results just call:

stat.report("Code ID");

Thou can also provide an additional std::ostream& parameter to report() to redirect the logging on a different output. Also, you can use the get_total/min/max/average() methods to get the individual numeric data, without all the details of the logging. You can also extend Statistics to implement your own logging syntax.

To report all the measurements:

stat.report_all();

Same as above, you can redirect the output by providing a std::ostream& parameter.

Definition at line 66 of file statistics.hpp.

Constructor & Destructor Documentation

◆ Statistics()

Statistics::Statistics ( )

Constructor

Definition at line 30 of file statistics.cpp.

◆ ~Statistics()

Statistics::~Statistics ( )

Destructor

Definition at line 34 of file statistics.cpp.

Member Function Documentation

◆ get_average()

long double Statistics::get_average ( std::string  name)

Returns average execution of a certain quantity

Definition at line 147 of file statistics.cpp.

◆ get_last()

long double Statistics::get_last ( std::string  name)

Return last measurement of a certain quantity

Definition at line 177 of file statistics.cpp.

◆ get_max()

long double Statistics::get_max ( std::string  name)

Returns maximum execution of a certain quantity

Definition at line 167 of file statistics.cpp.

◆ get_min()

long double Statistics::get_min ( std::string  name)

Returns minimum execution of a certain quantity

Definition at line 157 of file statistics.cpp.

◆ get_total()

long double Statistics::get_total ( std::string  name)

Returns total execution of a certain quantity

Definition at line 137 of file statistics.cpp.

◆ quantity_exists()

bool Statistics::quantity_exists ( std::string  name)

Tells if a quantity with a certain name exists

Definition at line 36 of file statistics.cpp.

◆ report()

void Statistics::report ( std::string  name,
int  precision = 2,
std::ostream &  output = std::cout 
)

Dump the data of a certain quantity record

Definition at line 108 of file statistics.cpp.

◆ report_all()

void Statistics::report_all ( int  precision = 2,
std::ostream &  output = std::cout 
)

Dump the data of all the quantity records

Definition at line 71 of file statistics.cpp.

◆ reset()

void Statistics::reset ( std::string  name)

Reset a certain quantity record

Definition at line 82 of file statistics.cpp.

◆ reset_all()

void Statistics::reset_all ( )

Resets all the quantity records

Definition at line 61 of file statistics.cpp.

◆ store()

void Statistics::store ( std::string  name,
const double &  value 
)

Record the value of the specified quantity

Definition at line 40 of file statistics.cpp.

◆ turn_off()

void Statistics::turn_off ( )

Turn off statistics, all the Statistics::* methods return without doing anything after this method is called.

Definition at line 103 of file statistics.cpp.

◆ turn_on()

void Statistics::turn_on ( )

Turn on statistics, restore operativity after a turn_off().

Definition at line 98 of file statistics.cpp.

Member Data Documentation

◆ active

bool Statistics::active
protected

Flag to hold the statistics status

Definition at line 137 of file statistics.hpp.

◆ records_of

std::map<std::string, QuantityData>* Statistics::records_of
protected

Pointer to the dynamic structure which holds the collection of quantity data

Definition at line 141 of file statistics.hpp.


The documentation for this class was generated from the following files:
Statistics
A class to compute statistics about quantities of interest.
Definition: statistics.hpp:66


tsid
Author(s): Andrea Del Prete, Justin Carpentier
autogenerated on Sat May 3 2025 02:48:17