OLD | NEW |
---|---|
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 // BucketRanges stores the vector of ranges that delimit what samples are | 5 // BucketRanges stores the vector of ranges that delimit what samples are |
6 // tallied in the corresponding buckets of a histogram. Histograms that have | 6 // tallied in the corresponding buckets of a histogram. Histograms that have |
7 // same ranges for all their corresponding buckets should share the same | 7 // same ranges for all their corresponding buckets should share the same |
8 // BucketRanges object. | 8 // BucketRanges object. |
9 // | 9 // |
10 // E.g. A 5 buckets LinearHistogram with 1 as minimal value and 4 as maximal | 10 // E.g. A 5 buckets LinearHistogram with 1 as minimal value and 4 as maximal |
(...skipping 22 matching lines...) Expand all Loading... | |
33 | 33 |
34 class BASE_EXPORT BucketRanges { | 34 class BASE_EXPORT BucketRanges { |
35 public: | 35 public: |
36 typedef std::vector<HistogramBase::Sample> Ranges; | 36 typedef std::vector<HistogramBase::Sample> Ranges; |
37 | 37 |
38 explicit BucketRanges(size_t num_ranges); | 38 explicit BucketRanges(size_t num_ranges); |
39 ~BucketRanges(); | 39 ~BucketRanges(); |
40 | 40 |
41 size_t size() const { return ranges_.size(); } | 41 size_t size() const { return ranges_.size(); } |
42 HistogramBase::Sample range(size_t i) const { return ranges_[i]; } | 42 HistogramBase::Sample range(size_t i) const { return ranges_[i]; } |
43 void set_range(size_t i, HistogramBase::Sample value); | 43 void set_range(size_t i, HistogramBase::Sample value) { |
44 DCHECK_LT(i, ranges_.size()); | |
45 CHECK_GE(value, 0); | |
46 ranges_[i] = value; | |
Nico
2017/06/21 01:03:37
Kind of weird that one is a dcheck but the other a
hans
2017/06/21 01:11:46
Good point. It was added in https://chromiumcodere
| |
47 } | |
44 uint32_t checksum() const { return checksum_; } | 48 uint32_t checksum() const { return checksum_; } |
45 void set_checksum(uint32_t checksum) { checksum_ = checksum; } | 49 void set_checksum(uint32_t checksum) { checksum_ = checksum; } |
46 | 50 |
47 // A bucket is defined by a consecutive pair of entries in |ranges|, so there | 51 // A bucket is defined by a consecutive pair of entries in |ranges|, so there |
48 // is one fewer bucket than there are ranges. For example, if |ranges| is | 52 // is one fewer bucket than there are ranges. For example, if |ranges| is |
49 // [0, 1, 3, 7, INT_MAX], then the buckets in this histogram are | 53 // [0, 1, 3, 7, INT_MAX], then the buckets in this histogram are |
50 // [0, 1), [1, 3), [3, 7), and [7, INT_MAX). | 54 // [0, 1), [1, 3), [3, 7), and [7, INT_MAX). |
51 size_t bucket_count() const { return ranges_.size() - 1; } | 55 size_t bucket_count() const { return ranges_.size() - 1; } |
52 | 56 |
53 // Checksum methods to verify whether the ranges are corrupted (e.g. bad | 57 // Checksum methods to verify whether the ranges are corrupted (e.g. bad |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 DISALLOW_COPY_AND_ASSIGN(BucketRanges); | 96 DISALLOW_COPY_AND_ASSIGN(BucketRanges); |
93 }; | 97 }; |
94 | 98 |
95 ////////////////////////////////////////////////////////////////////////////// | 99 ////////////////////////////////////////////////////////////////////////////// |
96 // Expose only for test. | 100 // Expose only for test. |
97 BASE_EXPORT extern const uint32_t kCrcTable[256]; | 101 BASE_EXPORT extern const uint32_t kCrcTable[256]; |
98 | 102 |
99 } // namespace base | 103 } // namespace base |
100 | 104 |
101 #endif // BASE_METRICS_BUCKET_RANGES_H_ | 105 #endif // BASE_METRICS_BUCKET_RANGES_H_ |
OLD | NEW |