]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
c++-refactored statHistDump including clients and stubs
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 6 Dec 2011 22:23:56 +0000 (23:23 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 6 Dec 2011 22:23:56 +0000 (23:23 +0100)
src/HttpHeader.cc
src/StatHist.cc
src/StatHist.h
src/comm/ModEpoll.cc
src/stat.cc
src/tests/stub_StatHist.cc

index ca2e71a93259746461254af01a0ff270aad0f68e..bb61b5e0c6c092c9bed63bb3780e37cbfd4256a4 100644 (file)
@@ -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;
 }
 
index a6698bc8dbeef42faceb60c5dfb13c5037b10a4c..85f28bd3dc3dee134b4109e1cba3cc1e185818c6 100644 (file)
@@ -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;
     }
 }
index 8f071cac69db6c4baa5f87a1e2ab6cf9652b4aab..e128b4a48e8309790e6ad3cd93b490439523217f 100644 (file)
@@ -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);
index f0e01d8612c9cec53c5862028c3c0d61f33549ed..c0e0c770fea77d278a92997e92d3da3ce705ec04 100644 (file)
@@ -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);
 }
 
 /**
index 7de2de183861033b186ff07c9b0fa1cdd0e77876..033782e0172d72d4c06828e6899702593977d029 100644 (file)
@@ -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
index 7ffe85840d0dcfe5f76785c94205c65db91a48e0..9fb64c25255995ce099368a2bacda6aec5e1674a 100644 (file)
@@ -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
+}