Chromium Code Reviews| 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 std::swap(*minimum, *maximum); | 393 std::swap(*minimum, *maximum); |
| 394 } | 394 } |
| 395 if (*maximum == *minimum) { | 395 if (*maximum == *minimum) { |
| 396 check_okay = false; | 396 check_okay = false; |
| 397 *maximum = *minimum + 1; | 397 *maximum = *minimum + 1; |
| 398 } | 398 } |
| 399 if (*bucket_count < 3) { | 399 if (*bucket_count < 3) { |
| 400 check_okay = false; | 400 check_okay = false; |
| 401 *bucket_count = 3; | 401 *bucket_count = 3; |
| 402 } | 402 } |
| 403 // Very high bucket counts are wasteful. Use a sparse histogram instead. | |
| 404 // Value of 10002 equals a user-supplied value of 10k + 2 overflow buckets. | |
| 405 constexpr uint32_t kMaxBucketCount = 10002; | |
|
bcwhite
2017/05/25 19:21:41
Even 10k sounds really, really large.
Alexei Svitkine (slow)
2017/05/25 19:24:04
Yeah agreed. There was a unit test that was using
| |
| 406 if (*bucket_count > kMaxBucketCount) { | |
| 407 check_okay = false; | |
| 408 *bucket_count = kMaxBucketCount; | |
| 409 } | |
| 403 if (*bucket_count > static_cast<uint32_t>(*maximum - *minimum + 2)) { | 410 if (*bucket_count > static_cast<uint32_t>(*maximum - *minimum + 2)) { |
| 404 check_okay = false; | 411 check_okay = false; |
| 405 *bucket_count = static_cast<uint32_t>(*maximum - *minimum + 2); | 412 *bucket_count = static_cast<uint32_t>(*maximum - *minimum + 2); |
| 406 } | 413 } |
| 407 | 414 |
| 408 if (!check_okay) { | 415 if (!check_okay) { |
| 409 UMA_HISTOGRAM_SPARSE_SLOWLY("Histogram.BadConstructionArguments", | 416 UMA_HISTOGRAM_SPARSE_SLOWLY("Histogram.BadConstructionArguments", |
| 410 static_cast<Sample>(HashMetricName(name))); | 417 static_cast<Sample>(HashMetricName(name))); |
| 411 } | 418 } |
| 412 | 419 |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1210 Sample sample = custom_ranges[i]; | 1217 Sample sample = custom_ranges[i]; |
| 1211 if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1) | 1218 if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1) |
| 1212 return false; | 1219 return false; |
| 1213 if (sample != 0) | 1220 if (sample != 0) |
| 1214 has_valid_range = true; | 1221 has_valid_range = true; |
| 1215 } | 1222 } |
| 1216 return has_valid_range; | 1223 return has_valid_range; |
| 1217 } | 1224 } |
| 1218 | 1225 |
| 1219 } // namespace base | 1226 } // namespace base |
| OLD | NEW |