From: Francesco Chemolli Date: Tue, 6 Dec 2011 22:23:56 +0000 (+0100) Subject: c++-refactored statHistDump including clients and stubs X-Git-Tag: BumpSslServerFirst.take05~12^2~120^2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=968869860e7e1d45bd6ed19880b5b0ac20616104;p=thirdparty%2Fsquid.git c++-refactored statHistDump including clients and stubs --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index ca2e71a932..bb61b5e0c6 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -1688,19 +1688,19 @@ httpHeaderStatDump(const HttpHeaderStat * hs, StoreEntry * e) storeAppendPrintf(e, "\nField type distribution\n"); storeAppendPrintf(e, "%2s\t %-20s\t %5s\t %6s\n", "id", "name", "count", "#/header"); - statHistDump(&hs->fieldTypeDistr, e, httpHeaderFieldStatDumper); + hs->fieldTypeDistr.dump(e, httpHeaderFieldStatDumper); storeAppendPrintf(e, "\nCache-control directives distribution\n"); storeAppendPrintf(e, "%2s\t %-20s\t %5s\t %6s\n", "id", "name", "count", "#/cc_field"); - statHistDump(&hs->ccTypeDistr, e, httpHdrCcStatDumper); + hs->ccTypeDistr.dump(e, httpHdrCcStatDumper); storeAppendPrintf(e, "\nSurrogate-control directives distribution\n"); storeAppendPrintf(e, "%2s\t %-20s\t %5s\t %6s\n", "id", "name", "count", "#/sc_field"); - statHistDump(&hs->scTypeDistr, e, httpHdrScStatDumper); + hs->scTypeDistr.dump(e, httpHdrScStatDumper); storeAppendPrintf(e, "\nNumber of fields per header distribution\n"); storeAppendPrintf(e, "%2s\t %-5s\t %5s\t %6s\n", "id", "#flds", "count", "%total"); - statHistDump(&hs->hdrUCountDistr, e, httpHeaderFldsPerHdrDumper); + hs->hdrUCountDistr.dump(e, httpHeaderFldsPerHdrDumper); dump_stat = NULL; } diff --git a/src/StatHist.cc b/src/StatHist.cc index a6698bc8db..85f28bd3dc 100644 --- a/src/StatHist.cc +++ b/src/StatHist.cc @@ -218,18 +218,18 @@ statHistBinDumper(StoreEntry * sentry, int idx, double val, double size, int cou } void -statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper * bd) +StatHist::dump(StoreEntry * sentry, StatHistBinDumper * bd) const { int i; - double left_border = H->min; + double left_border = min; if (!bd) bd = statHistBinDumper; - for (i = 0; i < H->capacity; i++) { - const double right_border = H->val(i + 1); + for (i = 0; i < capacity; ++i) { + const double right_border = val(i + 1); assert(right_border - left_border > 0.0); - bd(sentry, i, left_border, right_border - left_border, H->bins[i]); + bd(sentry, i, left_border, right_border - left_border, bins[i]); left_border = right_border; } } diff --git a/src/StatHist.h b/src/StatHist.h index 8f071cac69..e128b4a48e 100644 --- a/src/StatHist.h +++ b/src/StatHist.h @@ -55,7 +55,7 @@ public: StatHist() : bins(NULL), capacity(0), min(0), max(0), scale(1.0), val_in(NULL), val_out(NULL) {}; StatHist(const StatHist&); - void dump(StoreEntry *sentry, StatHistBinDumper * bd); + void dump(StoreEntry *sentry, StatHistBinDumper * bd) const; void logInit(int capacity, double min, double max); void enumInit(int last_enum); void intInit(int n); @@ -68,7 +68,6 @@ private: void statHistCount(StatHist * H, double val); double statHistDeltaMedian(const StatHist & A, const StatHist & B); double statHistDeltaPctile(const StatHist & A, const StatHist & B, double pctile); -void statHistDump(const StatHist * H, StoreEntry * sentry, StatHistBinDumper * bd); void statHistLogInit(StatHist * H, int capacity, double min, double max); void statHistEnumInit(StatHist * H, int last_enum); void statHistIntInit(StatHist * H, int n); diff --git a/src/comm/ModEpoll.cc b/src/comm/ModEpoll.cc index f0e01d8612..c0e0c770fe 100644 --- a/src/comm/ModEpoll.cc +++ b/src/comm/ModEpoll.cc @@ -228,7 +228,7 @@ commIncomingStats(StoreEntry * sentry) StatCounters *f = &statCounter; storeAppendPrintf(sentry, "Total number of epoll(2) loops: %ld\n", statCounter.select_loops); storeAppendPrintf(sentry, "Histogram of returned filedescriptors\n"); - statHistDump(&f->select_fds_hist, sentry, statHistIntDumper); + f->select_fds_hist.dump(sentry, statHistIntDumper); } /** diff --git a/src/stat.cc b/src/stat.cc index 7de2de1838..033782e017 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1559,25 +1559,24 @@ statCountersCopy(StatCounters * dest, const StatCounters * orig) static void statCountersHistograms(StoreEntry * sentry) { - StatCounters *f = &statCounter; storeAppendPrintf(sentry, "client_http.all_svc_time histogram:\n"); - statHistDump(&f->client_http.all_svc_time, sentry, NULL); + statCounter.client_http.all_svc_time.dump(sentry, NULL); storeAppendPrintf(sentry, "client_http.miss_svc_time histogram:\n"); - statHistDump(&f->client_http.miss_svc_time, sentry, NULL); + statCounter.client_http.miss_svc_time.dump(sentry, NULL); storeAppendPrintf(sentry, "client_http.nm_svc_time histogram:\n"); - statHistDump(&f->client_http.nm_svc_time, sentry, NULL); + statCounter.client_http.nm_svc_time.dump(sentry, NULL); storeAppendPrintf(sentry, "client_http.nh_svc_time histogram:\n"); - statHistDump(&f->client_http.nh_svc_time, sentry, NULL); + statCounter.client_http.nh_svc_time.dump(sentry, NULL); storeAppendPrintf(sentry, "client_http.hit_svc_time histogram:\n"); - statHistDump(&f->client_http.hit_svc_time, sentry, NULL); + statCounter.client_http.hit_svc_time.dump(sentry, NULL); storeAppendPrintf(sentry, "icp.query_svc_time histogram:\n"); - statHistDump(&f->icp.query_svc_time, sentry, NULL); + statCounter.icp.query_svc_time.dump(sentry, NULL); storeAppendPrintf(sentry, "icp.reply_svc_time histogram:\n"); - statHistDump(&f->icp.reply_svc_time, sentry, NULL); + statCounter.icp.reply_svc_time.dump(sentry, NULL); storeAppendPrintf(sentry, "dns.svc_time histogram:\n"); - statHistDump(&f->dns.svc_time, sentry, NULL); + statCounter.dns.svc_time.dump(sentry, NULL); storeAppendPrintf(sentry, "select_fds_hist histogram:\n"); - statHistDump(&f->select_fds_hist, sentry, NULL); + statCounter.select_fds_hist.dump(sentry, NULL); } static void diff --git a/src/tests/stub_StatHist.cc b/src/tests/stub_StatHist.cc index 7ffe85840d..9fb64c2525 100644 --- a/src/tests/stub_StatHist.cc +++ b/src/tests/stub_StatHist.cc @@ -20,3 +20,9 @@ statHistEnumInit(StatHist * H, int last_enum) { //NO-OP fatal("statHistEnumInit: Not implemented"); } + +void +StatHist::dump(StoreEntry * sentry, StatHistBinDumper * bd) const +{ + // noop +}