OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/disk_cache/blockfile/stats.h" | 5 #include "net/disk_cache/blockfile/stats.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/bucket_ranges.h" | 9 #include "base/metrics/bucket_ranges.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 for (int i = 4; i >= 0; i--) { | 36 for (int i = 4; i >= 0; i--) { |
37 if (value & mask[i]) { | 37 if (value & mask[i]) { |
38 value >>= s[i]; | 38 value >>= s[i]; |
39 result |= s[i]; | 39 result |= s[i]; |
40 } | 40 } |
41 } | 41 } |
42 return static_cast<int>(result); | 42 return static_cast<int>(result); |
43 } | 43 } |
44 | 44 |
45 // WARNING: Add new stats only at the end, or change LoadStats(). | 45 // WARNING: Add new stats only at the end, or change LoadStats(). |
46 static const char* kCounterNames[] = { | 46 const char* const kCounterNames[] = { |
47 "Open miss", | 47 "Open miss", |
48 "Open hit", | 48 "Open hit", |
49 "Create miss", | 49 "Create miss", |
50 "Create hit", | 50 "Create hit", |
51 "Resurrect hit", | 51 "Resurrect hit", |
52 "Create error", | 52 "Create error", |
53 "Trim entry", | 53 "Trim entry", |
54 "Doom entry", | 54 "Doom entry", |
55 "Doom cache", | 55 "Doom cache", |
56 "Invalid entry", | 56 "Invalid entry", |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 int Stats::GetRatio(Counters hit, Counters miss) const { | 310 int Stats::GetRatio(Counters hit, Counters miss) const { |
311 int64 ratio = GetCounter(hit) * 100; | 311 int64 ratio = GetCounter(hit) * 100; |
312 if (!ratio) | 312 if (!ratio) |
313 return 0; | 313 return 0; |
314 | 314 |
315 ratio /= (GetCounter(hit) + GetCounter(miss)); | 315 ratio /= (GetCounter(hit) + GetCounter(miss)); |
316 return static_cast<int>(ratio); | 316 return static_cast<int>(ratio); |
317 } | 317 } |
318 | 318 |
319 } // namespace disk_cache | 319 } // namespace disk_cache |
OLD | NEW |