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 // 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 return NULL; | 121 return NULL; |
122 } | 122 } |
123 return histogram; | 123 return histogram; |
124 } | 124 } |
125 | 125 |
126 HistogramBase* Histogram::FactoryTimeGet(const string& name, | 126 HistogramBase* Histogram::FactoryTimeGet(const string& name, |
127 TimeDelta minimum, | 127 TimeDelta minimum, |
128 TimeDelta maximum, | 128 TimeDelta maximum, |
129 size_t bucket_count, | 129 size_t bucket_count, |
130 int32 flags) { | 130 int32 flags) { |
131 return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(), | 131 return FactoryGet(name, static_cast<Sample>(minimum.InMilliseconds()), |
132 bucket_count, flags); | 132 static_cast<Sample>(maximum.InMilliseconds()), bucket_count, |
| 133 flags); |
133 } | 134 } |
134 | 135 |
135 // Calculate what range of values are held in each bucket. | 136 // Calculate what range of values are held in each bucket. |
136 // We have to be careful that we don't pick a ratio between starting points in | 137 // We have to be careful that we don't pick a ratio between starting points in |
137 // consecutive buckets that is sooo small, that the integer bounds are the same | 138 // consecutive buckets that is sooo small, that the integer bounds are the same |
138 // (effectively making one bucket get no values). We need to avoid: | 139 // (effectively making one bucket get no values). We need to avoid: |
139 // ranges(i) == ranges(i + 1) | 140 // ranges(i) == ranges(i + 1) |
140 // To avoid that, we just do a fine-grained bucket width as far as we need to | 141 // To avoid that, we just do a fine-grained bucket width as far as we need to |
141 // until we get a ratio that moves us along at least 2 units at a time. From | 142 // until we get a ratio that moves us along at least 2 units at a time. From |
142 // that bucket onward we do use the exponential growth of buckets. | 143 // that bucket onward we do use the exponential growth of buckets. |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 int32 flags) { | 522 int32 flags) { |
522 return FactoryGetWithRangeDescription( | 523 return FactoryGetWithRangeDescription( |
523 name, minimum, maximum, bucket_count, flags, NULL); | 524 name, minimum, maximum, bucket_count, flags, NULL); |
524 } | 525 } |
525 | 526 |
526 HistogramBase* LinearHistogram::FactoryTimeGet(const string& name, | 527 HistogramBase* LinearHistogram::FactoryTimeGet(const string& name, |
527 TimeDelta minimum, | 528 TimeDelta minimum, |
528 TimeDelta maximum, | 529 TimeDelta maximum, |
529 size_t bucket_count, | 530 size_t bucket_count, |
530 int32 flags) { | 531 int32 flags) { |
531 return FactoryGet(name, minimum.InMilliseconds(), maximum.InMilliseconds(), | 532 return FactoryGet(name, static_cast<Sample>(minimum.InMilliseconds()), |
532 bucket_count, flags); | 533 static_cast<Sample>(maximum.InMilliseconds()), bucket_count, |
| 534 flags); |
533 } | 535 } |
534 | 536 |
535 HistogramBase* LinearHistogram::FactoryGetWithRangeDescription( | 537 HistogramBase* LinearHistogram::FactoryGetWithRangeDescription( |
536 const std::string& name, | 538 const std::string& name, |
537 Sample minimum, | 539 Sample minimum, |
538 Sample maximum, | 540 Sample maximum, |
539 size_t bucket_count, | 541 size_t bucket_count, |
540 int32 flags, | 542 int32 flags, |
541 const DescriptionPair descriptions[]) { | 543 const DescriptionPair descriptions[]) { |
542 bool valid_arguments = Histogram::InspectConstructionArguments( | 544 bool valid_arguments = Histogram::InspectConstructionArguments( |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 | 837 |
836 BucketRanges* bucket_ranges = new BucketRanges(ranges.size()); | 838 BucketRanges* bucket_ranges = new BucketRanges(ranges.size()); |
837 for (size_t i = 0; i < ranges.size(); i++) { | 839 for (size_t i = 0; i < ranges.size(); i++) { |
838 bucket_ranges->set_range(i, ranges[i]); | 840 bucket_ranges->set_range(i, ranges[i]); |
839 } | 841 } |
840 bucket_ranges->ResetChecksum(); | 842 bucket_ranges->ResetChecksum(); |
841 return bucket_ranges; | 843 return bucket_ranges; |
842 } | 844 } |
843 | 845 |
844 } // namespace base | 846 } // namespace base |
OLD | NEW |