23 using std::ostringstream;
60 quant_info.
last = value;
63 if ( value >= quant_info.
max )
64 quant_info.
max = value;
65 if ( value <= quant_info.
min || quant_info.
min == 0 )
66 quant_info.
min = value;
69 quant_info.
total += value;
76 map<string, QuantityData>::iterator it;
87 output<<
"\n*** STATISTICS (min - avg - max - last - nSamples - total) ***\n";
88 map<string, QuantityData>::iterator it;
90 if(it->second.stops>0)
91 report(it->first, precision, output);
105 quant_info.
total = 0;
109 quant_info.
stops = 0;
114 std::cout <<
"Statistics active." << std::endl;
120 std::cout <<
"Statistics inactive." << std::endl;
138 output << name << pad;
139 output << std::fixed << std::setprecision(precision)
140 << (quant_info.
min) <<
"\t";
141 output << std::fixed << std::setprecision(precision)
142 << (quant_info.
total / (
long double) quant_info.
stops) <<
"\t";
143 output << std::fixed << std::setprecision(precision)
144 << (quant_info.
max) <<
"\t";
145 output << std::fixed << std::setprecision(precision)
146 << (quant_info.
last) <<
"\t";
147 output << std::fixed << std::setprecision(precision)
148 << quant_info.
stops <<
"\t";
149 output << std::fixed << std::setprecision(precision)
150 << quant_info.
total << std::endl;
161 return quant_info.
total;
173 return (quant_info.
total / (
long double)quant_info.
stops);
185 return quant_info.
min;
197 return quant_info.
max;
209 return quant_info.
last;
void report(std::string name, int precision=2, std::ostream &output=std::cout)
bool quantity_exists(std::string name)
long double get_total(std::string name)
A class to compute statistics about quantities of interest.
#define STATISTICS_MAX_NAME_LENGTH
Statistics & getStatistics()
void reset(std::string name)
std::map< std::string, QuantityData > * records_of
long double get_min(std::string name)
long double get_average(std::string name)
long double get_max(std::string name)
long double get_last(std::string name)
void store(std::string name, const double &value)
void report_all(int precision=2, std::ostream &output=std::cout)