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

Side by Side Diff: base/metrics/histogram.cc

Issue 1002103004: NOT FOR REVIEW - Slow Reports Reference Implementation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: JSON serialization. Created 5 years, 7 months 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
« no previous file with comments | « no previous file | base/metrics/histogram_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Histogram is an object that aggregates statistics, and can summarize them in 5 // Histogram is an object that aggregates statistics, and can summarize them in
6 // various forms, including ASCII graphical, HTML, and numerically (as a 6 // various forms, including ASCII graphical, HTML, and numerically (as a
7 // vector of numbers corresponding to each of the aggregating buckets). 7 // vector of numbers corresponding to each of the aggregating buckets).
8 // See header file for details and examples. 8 // See header file for details and examples.
9 9
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 void Histogram::Add(int value) { 259 void Histogram::Add(int value) {
260 DCHECK_EQ(0, ranges(0)); 260 DCHECK_EQ(0, ranges(0));
261 DCHECK_EQ(kSampleType_MAX, ranges(bucket_count())); 261 DCHECK_EQ(kSampleType_MAX, ranges(bucket_count()));
262 262
263 if (value > kSampleType_MAX - 1) 263 if (value > kSampleType_MAX - 1)
264 value = kSampleType_MAX - 1; 264 value = kSampleType_MAX - 1;
265 if (value < 0) 265 if (value < 0)
266 value = 0; 266 value = 0;
267 samples_->Accumulate(value, 1); 267 samples_->Accumulate(value, 1);
268
269 if (UNLIKELY(!callback_.is_null()))
270 callback_.Run();
268 } 271 }
269 272
270 scoped_ptr<HistogramSamples> Histogram::SnapshotSamples() const { 273 scoped_ptr<HistogramSamples> Histogram::SnapshotSamples() const {
271 return SnapshotSampleVector().Pass(); 274 return SnapshotSampleVector().Pass();
272 } 275 }
273 276
274 void Histogram::AddSamples(const HistogramSamples& samples) { 277 void Histogram::AddSamples(const HistogramSamples& samples) {
275 samples_->Add(samples); 278 samples_->Add(samples);
276 } 279 }
277 280
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 840
838 BucketRanges* bucket_ranges = new BucketRanges(ranges.size()); 841 BucketRanges* bucket_ranges = new BucketRanges(ranges.size());
839 for (size_t i = 0; i < ranges.size(); i++) { 842 for (size_t i = 0; i < ranges.size(); i++) {
840 bucket_ranges->set_range(i, ranges[i]); 843 bucket_ranges->set_range(i, ranges[i]);
841 } 844 }
842 bucket_ranges->ResetChecksum(); 845 bucket_ranges->ResetChecksum();
843 return bucket_ranges; 846 return bucket_ranges;
844 } 847 }
845 848
846 } // namespace base 849 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/metrics/histogram_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698