| OLD | NEW |
| 1 // Copyright (c) 2011 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. |
| 11 | 11 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 // samples we've accumulated into all of our buckets. We can compare this | 423 // samples we've accumulated into all of our buckets. We can compare this |
| 424 // count to the sum of the counts in all buckets, and detect problems. Note | 424 // count to the sum of the counts in all buckets, and detect problems. Note |
| 425 // that due to races in histogram accumulation (if a histogram is indeed | 425 // that due to races in histogram accumulation (if a histogram is indeed |
| 426 // updated on several threads simultaneously), the tallies might mismatch, | 426 // updated on several threads simultaneously), the tallies might mismatch, |
| 427 // and also the snapshotting code may asynchronously get a mismatch (though | 427 // and also the snapshotting code may asynchronously get a mismatch (though |
| 428 // generally either race based mismatch cause is VERY rare). | 428 // generally either race based mismatch cause is VERY rare). |
| 429 int64 redundant_count_; | 429 int64 redundant_count_; |
| 430 }; | 430 }; |
| 431 | 431 |
| 432 //---------------------------------------------------------------------------- | 432 //---------------------------------------------------------------------------- |
| 433 // minimum should start from 1. 0 is invalid as a minimum. 0 is an implicit | 433 // For a valid histogram, input should follow these restrictions: |
| 434 // default underflow bucket. | 434 // minimum > 0 (if a minimum below 1 is specified, it will implicitly be |
| 435 // normalized up to 1) |
| 436 // maximum > minimum |
| 437 // buckets > 2 [minimum buckets needed: underflow, overflow and the range] |
| 438 // Additionally, |
| 439 // buckets <= (maximum - minimum + 2) - this is to ensure that we don't have |
| 440 // more buckets than the range of numbers; having more buckets than 1 per |
| 441 // value in the range would be nonsensical. |
| 435 static Histogram* FactoryGet(const std::string& name, | 442 static Histogram* FactoryGet(const std::string& name, |
| 436 Sample minimum, | 443 Sample minimum, |
| 437 Sample maximum, | 444 Sample maximum, |
| 438 size_t bucket_count, | 445 size_t bucket_count, |
| 439 Flags flags); | 446 Flags flags); |
| 440 static Histogram* FactoryTimeGet(const std::string& name, | 447 static Histogram* FactoryTimeGet(const std::string& name, |
| 441 base::TimeDelta minimum, | 448 base::TimeDelta minimum, |
| 442 base::TimeDelta maximum, | 449 base::TimeDelta maximum, |
| 443 size_t bucket_count, | 450 size_t bucket_count, |
| 444 Flags flags); | 451 Flags flags); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 // of our data, and to quickly see if some other CachedRanges instance is | 892 // of our data, and to quickly see if some other CachedRanges instance is |
| 886 // possibly Equal() to this instance. | 893 // possibly Equal() to this instance. |
| 887 uint32 range_checksum_; | 894 uint32 range_checksum_; |
| 888 | 895 |
| 889 DISALLOW_COPY_AND_ASSIGN(CachedRanges); | 896 DISALLOW_COPY_AND_ASSIGN(CachedRanges); |
| 890 }; | 897 }; |
| 891 | 898 |
| 892 } // namespace base | 899 } // namespace base |
| 893 | 900 |
| 894 #endif // BASE_METRICS_HISTOGRAM_H_ | 901 #endif // BASE_METRICS_HISTOGRAM_H_ |
| OLD | NEW |