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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 class Histogram; | 362 class Histogram; |
363 class LinearHistogram; | 363 class LinearHistogram; |
364 | 364 |
365 class BASE_EXPORT Histogram : public HistogramBase { | 365 class BASE_EXPORT Histogram : public HistogramBase { |
366 public: | 366 public: |
367 // Initialize maximum number of buckets in histograms as 16,384. | 367 // Initialize maximum number of buckets in histograms as 16,384. |
368 static const size_t kBucketCount_MAX; | 368 static const size_t kBucketCount_MAX; |
369 | 369 |
370 typedef std::vector<Count> Counts; | 370 typedef std::vector<Count> Counts; |
371 | 371 |
372 enum Inconsistencies { | |
373 NO_INCONSISTENCIES = 0x0, | |
374 RANGE_CHECKSUM_ERROR = 0x1, | |
375 BUCKET_ORDER_ERROR = 0x2, | |
376 COUNT_HIGH_ERROR = 0x4, | |
377 COUNT_LOW_ERROR = 0x8, | |
378 | |
379 NEVER_EXCEEDED_VALUE = 0x10 | |
380 }; | |
381 | |
382 //---------------------------------------------------------------------------- | 372 //---------------------------------------------------------------------------- |
383 // For a valid histogram, input should follow these restrictions: | 373 // For a valid histogram, input should follow these restrictions: |
384 // minimum > 0 (if a minimum below 1 is specified, it will implicitly be | 374 // minimum > 0 (if a minimum below 1 is specified, it will implicitly be |
385 // normalized up to 1) | 375 // normalized up to 1) |
386 // maximum > minimum | 376 // maximum > minimum |
387 // buckets > 2 [minimum buckets needed: underflow, overflow and the range] | 377 // buckets > 2 [minimum buckets needed: underflow, overflow and the range] |
388 // Additionally, | 378 // Additionally, |
389 // buckets <= (maximum - minimum + 2) - this is to ensure that we don't have | 379 // buckets <= (maximum - minimum + 2) - this is to ensure that we don't have |
390 // more buckets than the range of numbers; having more buckets than 1 per | 380 // more buckets than the range of numbers; having more buckets than 1 per |
391 // value in the range would be nonsensical. | 381 // value in the range would be nonsensical. |
(...skipping 24 matching lines...) Expand all Loading... |
416 // certain amount of slop before flagging this as an inconsistency. Even with | 406 // certain amount of slop before flagging this as an inconsistency. Even with |
417 // an inconsistency, we'll snapshot it again (for UMA in about a half hour), | 407 // an inconsistency, we'll snapshot it again (for UMA in about a half hour), |
418 // so we'll eventually get the data, if it was not the result of a corruption. | 408 // so we'll eventually get the data, if it was not the result of a corruption. |
419 static const int kCommonRaceBasedCountMismatch; | 409 static const int kCommonRaceBasedCountMismatch; |
420 | 410 |
421 // Check to see if bucket ranges, counts and tallies in the snapshot are | 411 // Check to see if bucket ranges, counts and tallies in the snapshot are |
422 // consistent with the bucket ranges and checksums in our histogram. This can | 412 // consistent with the bucket ranges and checksums in our histogram. This can |
423 // produce a false-alarm if a race occurred in the reading of the data during | 413 // produce a false-alarm if a race occurred in the reading of the data during |
424 // a SnapShot process, but should otherwise be false at all times (unless we | 414 // a SnapShot process, but should otherwise be false at all times (unless we |
425 // have memory over-writes, or DRAM failures). | 415 // have memory over-writes, or DRAM failures). |
426 virtual Inconsistencies FindCorruption(const HistogramSamples& samples) const; | 416 virtual int FindCorruption(const HistogramSamples& samples) const OVERRIDE; |
427 | 417 |
428 //---------------------------------------------------------------------------- | 418 //---------------------------------------------------------------------------- |
429 // Accessors for factory constuction, serialization and testing. | 419 // Accessors for factory constuction, serialization and testing. |
430 //---------------------------------------------------------------------------- | 420 //---------------------------------------------------------------------------- |
431 Sample declared_min() const { return declared_min_; } | 421 Sample declared_min() const { return declared_min_; } |
432 Sample declared_max() const { return declared_max_; } | 422 Sample declared_max() const { return declared_max_; } |
433 virtual Sample ranges(size_t i) const; | 423 virtual Sample ranges(size_t i) const; |
434 virtual size_t bucket_count() const; | 424 virtual size_t bucket_count() const; |
435 const BucketRanges* bucket_ranges() const { return bucket_ranges_; } | 425 const BucketRanges* bucket_ranges() const { return bucket_ranges_; } |
436 | 426 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); | 678 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); |
689 static BucketRanges* CreateBucketRangesFromCustomRanges( | 679 static BucketRanges* CreateBucketRangesFromCustomRanges( |
690 const std::vector<Sample>& custom_ranges); | 680 const std::vector<Sample>& custom_ranges); |
691 | 681 |
692 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); | 682 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); |
693 }; | 683 }; |
694 | 684 |
695 } // namespace base | 685 } // namespace base |
696 | 686 |
697 #endif // BASE_METRICS_HISTOGRAM_H_ | 687 #endif // BASE_METRICS_HISTOGRAM_H_ |
OLD | NEW |