Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: net/disk_cache/blockfile/stats.cc

Issue 1471073007: Reorganize histograms for persistence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shmem-alloc
Patch Set: added GN changes Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 int min = 1; 143 int min = 1;
144 int max = 64 * 1024; 144 int max = 64 * 1024;
145 int num_buckets = 75; 145 int num_buckets = 75;
146 base::BucketRanges ranges(num_buckets + 1); 146 base::BucketRanges ranges(num_buckets + 1);
147 base::Histogram::InitializeBucketRanges(min, max, &ranges); 147 base::Histogram::InitializeBucketRanges(min, max, &ranges);
148 148
149 base::HistogramBase* stats_histogram = base::Histogram::FactoryGet( 149 base::HistogramBase* stats_histogram = base::Histogram::FactoryGet(
150 "DiskCache.SizeStats2", min, max, num_buckets, 150 "DiskCache.SizeStats2", min, max, num_buckets,
151 base::HistogramBase::kUmaTargetedHistogramFlag); 151 base::HistogramBase::kUmaTargetedHistogramFlag);
152 152
153 base::SampleVector samples(&ranges); 153 base::SampleVector samples(0, &ranges);
154 for (int i = 0; i < kDataSizesLength; i++) { 154 for (int i = 0; i < kDataSizesLength; i++) {
155 // This is a good time to fix any inconsistent data. The count should be 155 // This is a good time to fix any inconsistent data. The count should be
156 // always positive, but if it's not, reset the value now. 156 // always positive, but if it's not, reset the value now.
157 if (data_sizes_[i] < 0) 157 if (data_sizes_[i] < 0)
158 data_sizes_[i] = 0; 158 data_sizes_[i] = 0;
159 159
160 samples.Accumulate(GetBucketRange(i) / 1024, data_sizes_[i]); 160 samples.Accumulate(GetBucketRange(i) / 1024, data_sizes_[i]);
161 } 161 }
162 stats_histogram->AddSamples(samples); 162 stats_histogram->AddSamples(samples);
163 } 163 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 int Stats::GetRatio(Counters hit, Counters miss) const { 320 int Stats::GetRatio(Counters hit, Counters miss) const {
321 int64 ratio = GetCounter(hit) * 100; 321 int64 ratio = GetCounter(hit) * 100;
322 if (!ratio) 322 if (!ratio)
323 return 0; 323 return 0;
324 324
325 ratio /= (GetCounter(hit) + GetCounter(miss)); 325 ratio /= (GetCounter(hit) + GetCounter(miss));
326 return static_cast<int>(ratio); 326 return static_cast<int>(ratio);
327 } 327 }
328 328
329 } // namespace disk_cache 329 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698