summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/stats.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-24 23:51:25 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-24 23:51:25 +0000
commite2951cf3bd7e591a64ad5199a61531dac0ec58d2 (patch)
tree3039f816f6fa46008865c1ce4b1dd15de7b48d5a /net/disk_cache/stats.cc
parent0e8db94aef1b57355c3d154cb4682ce2f94c51eb (diff)
downloadchromium_src-e2951cf3bd7e591a64ad5199a61531dac0ec58d2.zip
chromium_src-e2951cf3bd7e591a64ad5199a61531dac0ec58d2.tar.gz
chromium_src-e2951cf3bd7e591a64ad5199a61531dac0ec58d2.tar.bz2
Use histograms to send interesting parts of the disk cache statistics.
Most of this CL deals with a derived implementation of histograms that just queries the size stats already generated by the disk cache. The exact number of buckets, and their distribution, is controlled directly by the new class and the disk cache stats code. Review URL: http://codereview.chromium.org/3069 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/stats.cc')
-rw-r--r--net/disk_cache/stats.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/net/disk_cache/stats.cc b/net/disk_cache/stats.cc
index d57a0bb..83448d5 100644
--- a/net/disk_cache/stats.cc
+++ b/net/disk_cache/stats.cc
@@ -120,6 +120,8 @@ bool Stats::Init(BackendImpl* backend, uint32* storage_addr) {
storage_addr_ = address.value();
backend_ = backend;
+ size_histogram_.reset(new StatsHistogram(L"DiskCache.SizeStats"));
+ size_histogram_->Init(this);
memcpy(data_sizes_, stats.data_sizes, sizeof(data_sizes_));
memcpy(counters_, stats.counters, sizeof(counters_));
@@ -184,6 +186,37 @@ int Stats::GetStatsBucket(int32 size) {
return result;
}
+int Stats::GetBucketRange(size_t i) const {
+ if (i < 2)
+ return static_cast<int>(1024 * i);
+
+ if (i < 12)
+ return static_cast<int>(2048 * (i - 1));
+
+ if (i < 17)
+ return static_cast<int>(4096 * (i - 11)) + 20 * 1024;
+
+ int n = 64 * 1024;
+ if (i > static_cast<size_t>(kDataSizesLength)) {
+ NOTREACHED();
+ i = kDataSizesLength;
+ }
+
+ i -= 17;
+ n <<= i;
+ return n;
+}
+
+void Stats::Snapshot(StatsHistogram::StatsSamples* samples) const {
+ samples->GetCounts()->resize(kDataSizesLength);
+ for (int i = 0; i < kDataSizesLength; i++) {
+ int count = data_sizes_[i];
+ if (count < 0)
+ count = 0;
+ samples->GetCounts()->at(i) = count;
+ }
+}
+
void Stats::ModifyStorageStats(int32 old_size, int32 new_size) {
// We keep a counter of the data block size on an array where each entry is
// the adjusted log base 2 of the size. The first entry counts blocks of 256