summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/stats.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-20 21:49:00 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-20 21:49:00 +0000
commit97ac07d0ffcca8e53812577472d62d76ae862d7b (patch)
tree00dc361586c14cb572a6aa3194758fb8b0fec059 /net/disk_cache/stats.cc
parent8e261756c62de3737c5dc9b9418857e2b58a7618 (diff)
downloadchromium_src-97ac07d0ffcca8e53812577472d62d76ae862d7b.zip
chromium_src-97ac07d0ffcca8e53812577472d62d76ae862d7b.tar.gz
chromium_src-97ac07d0ffcca8e53812577472d62d76ae862d7b.tar.bz2
Disk cache: More instrumentation for the cache.
Now we separate data between before and after the cache is full. Also, reduce the rate at which a particular client sends data to be only once a week. The effect is that the histogram data will only have one value per client, and the same client will not be "voting" on more than one version (release) at the same time. Review URL: http://codereview.chromium.org/50063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12218 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/stats.cc')
-rw-r--r--net/disk_cache/stats.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/net/disk_cache/stats.cc b/net/disk_cache/stats.cc
index 46c41a0..4f9440e 100644
--- a/net/disk_cache/stats.cc
+++ b/net/disk_cache/stats.cc
@@ -54,6 +54,8 @@ static const char* kCounterNames[] = {
"Open rankings",
"Get rankings",
"Fatal error",
+ "Last report",
+ "Last report timer"
};
COMPILE_ASSERT(arraysize(kCounterNames) == disk_cache::Stats::MAX_COUNTER,
update_the_names);
@@ -257,6 +259,40 @@ void Stats::GetItems(StatsItems* items) {
}
}
+int Stats::GetHitRatio() const {
+ return GetRatio(OPEN_HIT, OPEN_MISS);
+}
+
+int Stats::GetResurrectRatio() const {
+ return GetRatio(RESURRECT_HIT, CREATE_HIT);
+}
+
+int Stats::GetRatio(Counters hit, Counters miss) const {
+ int64 ratio = GetCounter(hit) * 100;
+ if (!ratio)
+ return 0;
+
+ ratio /= (GetCounter(hit) + GetCounter(miss));
+ return static_cast<int>(ratio);
+}
+
+void Stats::ResetRatios() {
+ SetCounter(OPEN_HIT, 0);
+ SetCounter(OPEN_MISS, 0);
+ SetCounter(RESURRECT_HIT, 0);
+ SetCounter(CREATE_HIT, 0);
+}
+
+int Stats::GetLargeEntriesSize() {
+ int total = 0;
+ // data_sizes_[20] stores values between 512 KB and 1 MB (see comment before
+ // GetStatsBucket()).
+ for (int bucket = 20; bucket < kDataSizesLength; bucket++)
+ total += data_sizes_[bucket] * GetBucketRange(bucket);
+
+ return total;
+}
+
void Stats::Store() {
if (!backend_)
return;