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 // 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 | 8 |
9 // It supports calls to accumulate either time intervals (which are processed | 9 // It supports calls to accumulate either time intervals (which are processed |
10 // as integral number of milliseconds), or arbitrary integral units. | 10 // as integral number of milliseconds), or arbitrary integral units. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // consistent with the bucket ranges and checksums in our histogram. This can | 166 // consistent with the bucket ranges and checksums in our histogram. This can |
167 // produce a false-alarm if a race occurred in the reading of the data during | 167 // produce a false-alarm if a race occurred in the reading of the data during |
168 // a SnapShot process, but should otherwise be false at all times (unless we | 168 // a SnapShot process, but should otherwise be false at all times (unless we |
169 // have memory over-writes, or DRAM failures). Flag definitions are located | 169 // have memory over-writes, or DRAM failures). Flag definitions are located |
170 // under "enum Inconsistency" in base/metrics/histogram_base.h. | 170 // under "enum Inconsistency" in base/metrics/histogram_base.h. |
171 uint32_t FindCorruption(const HistogramSamples& samples) const override; | 171 uint32_t FindCorruption(const HistogramSamples& samples) const override; |
172 | 172 |
173 //---------------------------------------------------------------------------- | 173 //---------------------------------------------------------------------------- |
174 // Accessors for factory construction, serialization and testing. | 174 // Accessors for factory construction, serialization and testing. |
175 //---------------------------------------------------------------------------- | 175 //---------------------------------------------------------------------------- |
176 Sample declared_min() const { return declared_min_; } | 176 Sample declared_min() const; |
177 Sample declared_max() const { return declared_max_; } | 177 Sample declared_max() const; |
178 virtual Sample ranges(uint32_t i) const; | 178 virtual Sample ranges(uint32_t i) const; |
179 virtual uint32_t bucket_count() const; | 179 virtual uint32_t bucket_count() const; |
180 const BucketRanges* bucket_ranges() const { return bucket_ranges_; } | 180 const BucketRanges* bucket_ranges() const { return bucket_ranges_; } |
181 | 181 |
182 // This function validates histogram construction arguments. It returns false | 182 // This function validates histogram construction arguments. It returns false |
183 // if some of the arguments are bad but also corrects them so they should | 183 // if some of the arguments are bad but also corrects them so they should |
184 // function on non-dcheck builds without crashing. | 184 // function on non-dcheck builds without crashing. |
185 // Note. Currently it allow some bad input, e.g. 0 as minimum, but silently | 185 // Note. Currently it allow some bad input, e.g. 0 as minimum, but silently |
186 // converts it to good input: 1. | 186 // converts it to good input: 1. |
187 // TODO(bcwhite): Use false returns to create "sink" histograms so that bad | 187 // TODO(bcwhite): Use false returns to create "sink" histograms so that bad |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // WriteJSON calls these. | 298 // WriteJSON calls these. |
299 void GetParameters(DictionaryValue* params) const override; | 299 void GetParameters(DictionaryValue* params) const override; |
300 | 300 |
301 void GetCountAndBucketData(Count* count, | 301 void GetCountAndBucketData(Count* count, |
302 int64_t* sum, | 302 int64_t* sum, |
303 ListValue* buckets) const override; | 303 ListValue* buckets) const override; |
304 | 304 |
305 // Does not own this object. Should get from StatisticsRecorder. | 305 // Does not own this object. Should get from StatisticsRecorder. |
306 const BucketRanges* bucket_ranges_; | 306 const BucketRanges* bucket_ranges_; |
307 | 307 |
308 Sample declared_min_; // Less than this goes into the first bucket. | |
309 Sample declared_max_; // Over this goes into the last bucket. | |
310 | |
311 // Samples that have not yet been logged with SnapshotDelta(). | 308 // Samples that have not yet been logged with SnapshotDelta(). |
312 std::unique_ptr<HistogramSamples> unlogged_samples_; | 309 std::unique_ptr<HistogramSamples> unlogged_samples_; |
313 | 310 |
314 // Accumulation of all samples that have been logged with SnapshotDelta(). | 311 // Accumulation of all samples that have been logged with SnapshotDelta(). |
315 std::unique_ptr<HistogramSamples> logged_samples_; | 312 std::unique_ptr<HistogramSamples> logged_samples_; |
316 | 313 |
| 314 #if DCHECK_IS_ON() // Don't waste memory if it won't be used. |
317 // Flag to indicate if PrepareFinalDelta has been previously called. It is | 315 // Flag to indicate if PrepareFinalDelta has been previously called. It is |
318 // used to DCHECK that a final delta is not created multiple times. | 316 // used to DCHECK that a final delta is not created multiple times. |
319 mutable bool final_delta_created_ = false; | 317 mutable bool final_delta_created_ = false; |
| 318 #endif |
320 | 319 |
321 DISALLOW_COPY_AND_ASSIGN(Histogram); | 320 DISALLOW_COPY_AND_ASSIGN(Histogram); |
322 }; | 321 }; |
323 | 322 |
324 //------------------------------------------------------------------------------ | 323 //------------------------------------------------------------------------------ |
325 | 324 |
326 // LinearHistogram is a more traditional histogram, with evenly spaced | 325 // LinearHistogram is a more traditional histogram, with evenly spaced |
327 // buckets. | 326 // buckets. |
328 class BASE_EXPORT LinearHistogram : public Histogram { | 327 class BASE_EXPORT LinearHistogram : public Histogram { |
329 public: | 328 public: |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 538 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
540 | 539 |
541 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); | 540 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); |
542 | 541 |
543 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); | 542 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); |
544 }; | 543 }; |
545 | 544 |
546 } // namespace base | 545 } // namespace base |
547 | 546 |
548 #endif // BASE_METRICS_HISTOGRAM_H_ | 547 #endif // BASE_METRICS_HISTOGRAM_H_ |
OLD | NEW |