Histograms related to region data should use filtered cache list

sql-rework
Tomasz Golinski 2020-07-17 19:57:46 +02:00
rodzic f03e3345f7
commit 193d6931a8
3 zmienionych plików z 20 dodań i 10 usunięć

Wyświetl plik

@ -48,6 +48,15 @@ static std::string string_mangle(const std::string& str) {
return tmp;
}
void show_histogram(const pCaches& fcc, std::string Cache::*ptr, const std::string& caption, bool html, bool sort_by_val) {
std::map<std::string, int> histogram;
for (auto el : fcc)
histogram[el->*ptr]++;
show_histogram(histogram, caption, html, sort_by_val);
}
void show_histogram(const Caches& cc, std::string Cache::*ptr, const std::string& caption, bool html, bool sort_by_val) {
std::map<std::string, int> histogram;
@ -106,12 +115,12 @@ void show_histogram(const std::map<std::string, int>& data, const std::string& c
}
}
void show_nested_histogram(const Caches& cc, std::string Cache::*ptr, std::string Cache::*ptr2, const std::string& caption, bool html, bool sort_by_val) {
void show_nested_histogram(const pCaches& fcc, std::string Cache::*ptr, std::string Cache::*ptr2, const std::string& caption, bool html, bool sort_by_val) {
std::map<std::string, int> histogram;
std::vector<std::pair<std::string, int>> pairs;
for (auto el : cc)
histogram[el.*ptr]++;
for (auto el : fcc)
histogram[el->*ptr]++;
std::copy(histogram.begin(), histogram.end(), std::back_inserter(pairs));
if (sort_by_val)
@ -136,9 +145,9 @@ void show_nested_histogram(const Caches& cc, std::string Cache::*ptr, std::strin
if (i < HIST_MAX) {
std::map<std::string, int> subhistogram;
std::vector<std::pair<std::string, int>> subpairs;
for (auto el : cc)
if (el.*ptr == own.first && !(el.*ptr2).empty()) //TODO problem with [unknown]
subhistogram[el.*ptr2]++;
for (auto el : fcc)
if (el->*ptr == own.first && !(el->*ptr2).empty()) //TODO problem with [unknown]
subhistogram[el->*ptr2]++;
if (!subhistogram.empty()) {
std::cout << "<details class=\"nested\"><summary class=\"bar\" style=\"--percent: " << 100 * own.second / max << "%;\"><span class=\"text\">" << own.first << ": " << own.second << "</span></summary>\n";
std::copy(subhistogram.begin(), subhistogram.end(), std::back_inserter(subpairs));

Wyświetl plik

@ -5,8 +5,9 @@
void htmlencode(std::string& data);
void show_histogram(const Caches& cc, std::string Cache::*ptr, const std::string& caption, bool html = 0, bool sort_by_val = 1);
void show_histogram(const pCaches& cc, std::string Cache::*ptr, const std::string& caption, bool html = 0, bool sort_by_val = 1);
void show_histogram(const std::map<std::string, int>& data, const std::string& caption, bool html = 0, bool sort_by_val = 1);
void show_nested_histogram(const Caches& cc, std::string Cache::*ptr, std::string Cache::*ptr2, const std::string& caption, bool html = 0, bool sort_by_val = 1);
void show_nested_histogram(const pCaches& fcc, std::string Cache::*ptr, std::string Cache::*ptr2, const std::string& caption, bool html = 0, bool sort_by_val = 1);
int find_streak(const std::multimap<std::time_t, const Cache*>& cc, std::time_t& start);

Wyświetl plik

@ -457,9 +457,9 @@ int main(int argc, char** argv) {
show_histogram(cc, &Cache::owner, "Cache owners", 1);
show_histogram(cc, &Cache::type, "Cache types", 1);
show_histogram(cc, &Cache::size, "Cache sizes", 1);
// show_histogram(cc, &Cache::region, "Regions", 1);
// show_histogram(cc, &Cache::subregion, "Subregions", 1);
show_nested_histogram(cc, &Cache::region, &Cache::subregion, "Regions", 1);
// show_histogram(fcc, &Cache::region, "Regions", 1);
// show_histogram(fcc, &Cache::subregion, "Subregions", 1);
show_nested_histogram(fcc, &Cache::region, &Cache::subregion, "Regions", 1);
show_histogram(cc, &Cache::day_of_week, "Days of the week", 1, 0);
show_histogram(cc, &Cache::mon, "Months", 1, 0);
show_histogram(cc, &Cache::year, "Years", 1, 0);