| 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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 return max; | 666 return max; |
| 667 } | 667 } |
| 668 | 668 |
| 669 void Histogram::WriteAsciiHeader(const SampleVector& samples, | 669 void Histogram::WriteAsciiHeader(const SampleVector& samples, |
| 670 Count sample_count, | 670 Count sample_count, |
| 671 std::string* output) const { | 671 std::string* output) const { |
| 672 StringAppendF(output, | 672 StringAppendF(output, |
| 673 "Histogram: %s recorded %d samples", | 673 "Histogram: %s recorded %d samples", |
| 674 histogram_name().c_str(), | 674 histogram_name().c_str(), |
| 675 sample_count); | 675 sample_count); |
| 676 if (0 == sample_count) { | 676 if (sample_count == 0) { |
| 677 DCHECK_EQ(samples.sum(), 0); | 677 DCHECK_EQ(samples.sum(), 0); |
| 678 } else { | 678 } else { |
| 679 double average = static_cast<float>(samples.sum()) / sample_count; | 679 double mean = static_cast<float>(samples.sum()) / sample_count; |
| 680 | 680 StringAppendF(output, ", mean = %.1f", mean); |
| 681 StringAppendF(output, ", average = %.1f", average); | |
| 682 } | 681 } |
| 683 if (flags() & ~kHexRangePrintingFlag) | 682 if (flags()) |
| 684 StringAppendF(output, " (flags = 0x%x)", flags() & ~kHexRangePrintingFlag); | 683 StringAppendF(output, " (flags = 0x%x)", flags()); |
| 685 } | 684 } |
| 686 | 685 |
| 687 void Histogram::WriteAsciiBucketContext(const int64_t past, | 686 void Histogram::WriteAsciiBucketContext(const int64_t past, |
| 688 const Count current, | 687 const Count current, |
| 689 const int64_t remaining, | 688 const int64_t remaining, |
| 690 const uint32_t i, | 689 const uint32_t i, |
| 691 std::string* output) const { | 690 std::string* output) const { |
| 692 double scaled_sum = (past + current + remaining) / 100.0; | 691 double scaled_sum = (past + current + remaining) / 100.0; |
| 693 WriteAsciiBucketValue(current, scaled_sum, output); | 692 WriteAsciiBucketValue(current, scaled_sum, output); |
| 694 if (0 < i) { | 693 if (0 < i) { |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 Sample sample = custom_ranges[i]; | 1178 Sample sample = custom_ranges[i]; |
| 1180 if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1) | 1179 if (sample < 0 || sample > HistogramBase::kSampleType_MAX - 1) |
| 1181 return false; | 1180 return false; |
| 1182 if (sample != 0) | 1181 if (sample != 0) |
| 1183 has_valid_range = true; | 1182 has_valid_range = true; |
| 1184 } | 1183 } |
| 1185 return has_valid_range; | 1184 return has_valid_range; |
| 1186 } | 1185 } |
| 1187 | 1186 |
| 1188 } // namespace base | 1187 } // namespace base |
| OLD | NEW |