kopia lustrzana https://gitlab.com/tomaszg/geostat
Add some total counts to owned caches stats
rodzic
2ef585d4a0
commit
e96a2ded1e
20
common.cpp
20
common.cpp
|
@ -262,3 +262,23 @@ float average(const Caches& cc, float Cache::*ptr) {
|
|||
float average(const Caches& cc, int Cache::*ptr) {
|
||||
return 1.0 * std::accumulate(cc.begin(), cc.end(), 0, [&](const float& a, const Cache& b) { return std::move(a) + b.*ptr; }) / cc.size();
|
||||
}
|
||||
|
||||
void sum_html(const Caches& cc, float Cache::*ptr, const std::string& caption) {
|
||||
std::cout << "<div class=\"basic_stats\">\n";
|
||||
std::cout << "Total " << caption << ": <span class=\"value\">" << sum(cc, ptr) << "</span><br>\n";
|
||||
std::cout << "</div>\n";
|
||||
}
|
||||
|
||||
void sum_html(const Caches& cc, int Cache::*ptr, const std::string& caption) {
|
||||
std::cout << "<div class=\"basic_stats\">\n";
|
||||
std::cout << "Total " << caption << ": <span class=\"value\">" << sum(cc, ptr) << "</span><br>\n";
|
||||
std::cout << "</div>\n";
|
||||
}
|
||||
|
||||
float sum(const Caches& cc, float Cache::*ptr) {
|
||||
return std::accumulate(cc.begin(), cc.end(), 0., [&](const float& a, const Cache& b) { return std::move(a) + b.*ptr; });
|
||||
}
|
||||
|
||||
int sum(const Caches& cc, int Cache::*ptr) {
|
||||
return std::accumulate(cc.begin(), cc.end(), 0, [&](const int& a, const Cache& b) { return std::move(a) + b.*ptr; });
|
||||
}
|
||||
|
|
5
common.h
5
common.h
|
@ -17,3 +17,8 @@ void average_html(const Caches& cc, float Cache::*ptr, const std::string& captio
|
|||
void average_html(const Caches& cc, int Cache::*ptr, const std::string& caption);
|
||||
float average(const Caches& cc, float Cache::*ptr);
|
||||
float average(const Caches& cc, int Cache::*ptr);
|
||||
|
||||
void sum_html(const Caches& cc, float Cache::*ptr, const std::string& caption);
|
||||
void sum_html(const Caches& cc, int Cache::*ptr, const std::string& caption);
|
||||
float sum(const Caches& cc, float Cache::*ptr);
|
||||
int sum(const Caches& cc, int Cache::*ptr);
|
||||
|
|
|
@ -852,6 +852,7 @@ int main(int argc, char** argv) {
|
|||
std::cout << "</table>\n";
|
||||
|
||||
average_html(cc, &Cache::fav, "number of recommendations");
|
||||
sum_html(cc, &Cache::fav, "number of recommendations");
|
||||
|
||||
n = 1;
|
||||
|
||||
|
@ -902,6 +903,7 @@ int main(int argc, char** argv) {
|
|||
std::cout << "</table>\n";
|
||||
|
||||
average_html(cc, &Cache::founds, "number of finds");
|
||||
sum_html(cc, &Cache::founds, "number of finds");
|
||||
|
||||
n = 1;
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue