A class to compute statistics about quantities of interest. More...
#include <sot/talos_balance/utils/statistics.hh>
Classes | |
struct | QuantityData |
Public Member Functions | |
Statistics () | |
~Statistics () | |
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 () |
void | store (std::string name, const double &value) |
void | turn_off () |
void | turn_on () |
Protected Attributes | |
bool | active |
std::map< std::string, QuantityData > * | records_of |
A class to compute statistics about quantities of interest.
The Statistics class can be used to keep track of the minimum, maximum, average of quantities of interest.
To report the results just call:
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:
Same as above, you can redirect the output by providing a std::ostream& parameter.
Definition at line 69 of file statistics.hh.
Statistics | ( | ) |
~Statistics | ( | ) |
long double get_average | ( | std::string | name | ) |
Returns average execution of a certain quantity
Definition at line 165 of file statistics.cpp.
References quantity_exists(), records_of, Statistics::QuantityData::stops, and Statistics::QuantityData::total.
long double get_last | ( | std::string | name | ) |
Return last measurement of a certain quantity
Definition at line 201 of file statistics.cpp.
References Statistics::QuantityData::last, quantity_exists(), and records_of.
long double get_max | ( | std::string | name | ) |
Returns maximum execution of a certain quantity
Definition at line 189 of file statistics.cpp.
References Statistics::QuantityData::max, quantity_exists(), and records_of.
long double get_min | ( | std::string | name | ) |
Returns minimum execution of a certain quantity
Definition at line 177 of file statistics.cpp.
References Statistics::QuantityData::min, quantity_exists(), and records_of.
long double get_total | ( | std::string | name | ) |
Returns total execution of a certain quantity
Definition at line 153 of file statistics.cpp.
References quantity_exists(), records_of, and Statistics::QuantityData::total.
bool quantity_exists | ( | std::string | name | ) |
Tells if a quantity with a certain name exists
Definition at line 43 of file statistics.cpp.
References records_of.
Referenced by get_average(), get_last(), get_max(), get_min(), get_total(), report(), and reset().
void report | ( | std::string | name, |
int | precision = 2 , |
||
std::ostream & | output = std::cout |
||
) |
Dump the data of a certain quantity record
Definition at line 124 of file statistics.cpp.
References active, Statistics::QuantityData::last, Statistics::QuantityData::max, Statistics::QuantityData::min, quantity_exists(), records_of, STATISTICS_MAX_NAME_LENGTH, Statistics::QuantityData::stops, and Statistics::QuantityData::total.
Referenced by report_all().
void report_all | ( | int | precision = 2 , |
std::ostream & | output = std::cout |
||
) |
Dump the data of all the quantity records
Definition at line 83 of file statistics.cpp.
References active, records_of, and report().
void reset | ( | std::string | name | ) |
Reset a certain quantity record
Definition at line 95 of file statistics.cpp.
References active, Statistics::QuantityData::last, Statistics::QuantityData::max, Statistics::QuantityData::min, quantity_exists(), records_of, Statistics::QuantityData::stops, and Statistics::QuantityData::total.
Referenced by reset_all().
void reset_all | ( | ) |
Resets all the quantity records
Definition at line 72 of file statistics.cpp.
References active, records_of, and reset().
Referenced by TalosControlManager::resetProfiler().
void store | ( | std::string | name, |
const double & | value | ||
) |
Record the value of the specified quantity
Definition at line 48 of file statistics.cpp.
References active, Statistics::QuantityData::last, Statistics::QuantityData::max, Statistics::QuantityData::min, records_of, Statistics::QuantityData::stops, and Statistics::QuantityData::total.
void turn_off | ( | ) |
Turn off statistics, all the Statistics::* methods return without doing anything after this method is called.
Definition at line 118 of file statistics.cpp.
References active.
void turn_on | ( | ) |
Turn on statistics, restore operativity after a turn_off().
Definition at line 112 of file statistics.cpp.
References active.
|
protected |
Flag to hold the statistics status
Definition at line 149 of file statistics.hh.
Referenced by report(), report_all(), reset(), reset_all(), store(), turn_off(), and turn_on().
|
protected |
Pointer to the dynamic structure which holds the collection of quantity data
Definition at line 153 of file statistics.hh.
Referenced by get_average(), get_last(), get_max(), get_min(), get_total(), quantity_exists(), report(), report_all(), reset(), reset_all(), Statistics(), store(), and ~Statistics().