OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 DCHECK_EQ(histogram->histogram_type(), CUSTOM_HISTOGRAM); | 933 DCHECK_EQ(histogram->histogram_type(), CUSTOM_HISTOGRAM); |
934 DCHECK(histogram->HasConstructorArguments(ranges[1], ranges.back(), | 934 DCHECK(histogram->HasConstructorArguments(ranges[1], ranges.back(), |
935 ranges.size())); | 935 ranges.size())); |
936 return histogram; | 936 return histogram; |
937 } | 937 } |
938 | 938 |
939 Histogram::ClassType CustomHistogram::histogram_type() const { | 939 Histogram::ClassType CustomHistogram::histogram_type() const { |
940 return CUSTOM_HISTOGRAM; | 940 return CUSTOM_HISTOGRAM; |
941 } | 941 } |
942 | 942 |
| 943 // static |
| 944 std::vector<Histogram::Sample> CustomHistogram::ArrayToCustomRanges( |
| 945 const Sample* values, size_t num_values) { |
| 946 std::vector<Sample> all_values; |
| 947 for (size_t i = 0; i < num_values; ++i) { |
| 948 Sample value = values[i]; |
| 949 all_values.push_back(value); |
| 950 |
| 951 // Ensure that a guard bucket is added. If we end up with duplicate |
| 952 // values, FactoryGet will take care of removing them. |
| 953 all_values.push_back(value + 1); |
| 954 } |
| 955 return all_values; |
| 956 } |
| 957 |
943 CustomHistogram::CustomHistogram(const std::string& name, | 958 CustomHistogram::CustomHistogram(const std::string& name, |
944 const std::vector<Sample>& custom_ranges) | 959 const std::vector<Sample>& custom_ranges) |
945 : Histogram(name, custom_ranges[1], custom_ranges.back(), | 960 : Histogram(name, custom_ranges[1], custom_ranges.back(), |
946 custom_ranges.size()) { | 961 custom_ranges.size()) { |
947 DCHECK_GT(custom_ranges.size(), 1u); | 962 DCHECK_GT(custom_ranges.size(), 1u); |
948 DCHECK_EQ(custom_ranges[0], 0); | 963 DCHECK_EQ(custom_ranges[0], 0); |
949 } | 964 } |
950 | 965 |
951 void CustomHistogram::InitializedCustomBucketRange( | 966 void CustomHistogram::InitializedCustomBucketRange( |
952 const std::vector<Sample>& custom_ranges) { | 967 const std::vector<Sample>& custom_ranges) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 } | 1137 } |
1123 | 1138 |
1124 // static | 1139 // static |
1125 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; | 1140 StatisticsRecorder::HistogramMap* StatisticsRecorder::histograms_ = NULL; |
1126 // static | 1141 // static |
1127 base::Lock* StatisticsRecorder::lock_ = NULL; | 1142 base::Lock* StatisticsRecorder::lock_ = NULL; |
1128 // static | 1143 // static |
1129 bool StatisticsRecorder::dump_on_exit_ = false; | 1144 bool StatisticsRecorder::dump_on_exit_ = false; |
1130 | 1145 |
1131 } // namespace base | 1146 } // namespace base |
OLD | NEW |