| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #define HISTOGRAM_COUNTS_100(name, sample) do { \ | 56 #define HISTOGRAM_COUNTS_100(name, sample) do { \ |
| 57 static Histogram counter((name), 1, 100, 50); \ | 57 static Histogram counter((name), 1, 100, 50); \ |
| 58 counter.Add(sample); \ | 58 counter.Add(sample); \ |
| 59 } while (0) | 59 } while (0) |
| 60 | 60 |
| 61 #define HISTOGRAM_COUNTS_10000(name, sample) do { \ | 61 #define HISTOGRAM_COUNTS_10000(name, sample) do { \ |
| 62 static Histogram counter((name), 1, 10000, 50); \ | 62 static Histogram counter((name), 1, 10000, 50); \ |
| 63 counter.Add(sample); \ | 63 counter.Add(sample); \ |
| 64 } while (0) | 64 } while (0) |
| 65 | 65 |
| 66 #define HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) do { \ |
| 67 static Histogram counter((name), min, max, bucket_count); \ |
| 68 counter.Add(sample); \ |
| 69 } while (0) |
| 70 |
| 66 #define HISTOGRAM_PERCENTAGE(name, under_one_hundred) do { \ | 71 #define HISTOGRAM_PERCENTAGE(name, under_one_hundred) do { \ |
| 67 static LinearHistogram counter((name), 1, 100, 101); \ | 72 static LinearHistogram counter((name), 1, 100, 101); \ |
| 68 counter.Add(under_one_hundred); \ | 73 counter.Add(under_one_hundred); \ |
| 69 } while (0) | 74 } while (0) |
| 70 | 75 |
| 71 // For folks that need real specific times, use this to select a precise range | 76 // For folks that need real specific times, use this to select a precise range |
| 72 // of times you want plotted, and the number of buckets you want used. | 77 // of times you want plotted, and the number of buckets you want used. |
| 73 #define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) do { \ | 78 #define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) do { \ |
| 74 static Histogram counter((name), min, max, bucket_count); \ | 79 static Histogram counter((name), min, max, bucket_count); \ |
| 75 counter.AddTime(sample); \ | 80 counter.AddTime(sample); \ |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 #define DHISTOGRAM_TIMES(name, sample) HISTOGRAM_TIMES(name, sample) | 116 #define DHISTOGRAM_TIMES(name, sample) HISTOGRAM_TIMES(name, sample) |
| 112 #define DHISTOGRAM_COUNTS(name, sample) HISTOGRAM_COUNTS(name, sample) | 117 #define DHISTOGRAM_COUNTS(name, sample) HISTOGRAM_COUNTS(name, sample) |
| 113 #define DASSET_HISTOGRAM_COUNTS(name, sample) ASSET_HISTOGRAM_COUNTS(name, \ | 118 #define DASSET_HISTOGRAM_COUNTS(name, sample) ASSET_HISTOGRAM_COUNTS(name, \ |
| 114 sample) | 119 sample) |
| 115 #define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) HISTOGRAM_PERCENTAGE(\ | 120 #define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) HISTOGRAM_PERCENTAGE(\ |
| 116 name, under_one_hundred) | 121 name, under_one_hundred) |
| 117 #define DHISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ | 122 #define DHISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ |
| 118 HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) | 123 HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) |
| 119 #define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \ | 124 #define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \ |
| 120 HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) | 125 HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) |
| 126 #define DHISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ |
| 127 HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) |
| 121 | 128 |
| 122 #else // NDEBUG | 129 #else // NDEBUG |
| 123 | 130 |
| 124 #define DHISTOGRAM_TIMES(name, sample) do {} while (0) | 131 #define DHISTOGRAM_TIMES(name, sample) do {} while (0) |
| 125 #define DHISTOGRAM_COUNTS(name, sample) do {} while (0) | 132 #define DHISTOGRAM_COUNTS(name, sample) do {} while (0) |
| 126 #define DASSET_HISTOGRAM_COUNTS(name, sample) do {} while (0) | 133 #define DASSET_HISTOGRAM_COUNTS(name, sample) do {} while (0) |
| 127 #define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) do {} while (0) | 134 #define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) do {} while (0) |
| 128 #define DHISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ | 135 #define DHISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ |
| 129 do {} while (0) | 136 do {} while (0) |
| 130 #define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \ | 137 #define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \ |
| 131 do {} while (0) | 138 do {} while (0) |
| 139 #define DHISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \ |
| 140 do {} while (0) |
| 141 |
| 132 | 142 |
| 133 #endif // NDEBUG | 143 #endif // NDEBUG |
| 134 | 144 |
| 135 //------------------------------------------------------------------------------ | 145 //------------------------------------------------------------------------------ |
| 136 // The following macros provide typical usage scenarios for callers that wish | 146 // The following macros provide typical usage scenarios for callers that wish |
| 137 // to record histogram data, and have the data submitted/uploaded via UMA. | 147 // to record histogram data, and have the data submitted/uploaded via UMA. |
| 138 // Not all systems support such UMA, but if they do, the following macros | 148 // Not all systems support such UMA, but if they do, the following macros |
| 139 // should work with the service. | 149 // should work with the service. |
| 140 | 150 |
| 141 static const int kUmaTargetedHistogramFlag = 0x1; | 151 static const int kUmaTargetedHistogramFlag = 0x1; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 counter.SetFlags(kUmaTargetedHistogramFlag); \ | 200 counter.SetFlags(kUmaTargetedHistogramFlag); \ |
| 191 counter.Add(sample); \ | 201 counter.Add(sample); \ |
| 192 } while (0) | 202 } while (0) |
| 193 | 203 |
| 194 #define UMA_HISTOGRAM_COUNTS_10000(name, sample) do { \ | 204 #define UMA_HISTOGRAM_COUNTS_10000(name, sample) do { \ |
| 195 static Histogram counter((name), 1, 10000, 50); \ | 205 static Histogram counter((name), 1, 10000, 50); \ |
| 196 counter.SetFlags(kUmaTargetedHistogramFlag); \ | 206 counter.SetFlags(kUmaTargetedHistogramFlag); \ |
| 197 counter.Add(sample); \ | 207 counter.Add(sample); \ |
| 198 } while (0) | 208 } while (0) |
| 199 | 209 |
| 210 #define UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) do { \ |
| 211 static Histogram counter((name), min, max, bucket_count); \ |
| 212 counter.SetFlags(kUmaTargetedHistogramFlag); \ |
| 213 counter.Add(sample); \ |
| 214 } while (0) |
| 215 |
| 200 #define UMA_HISTOGRAM_MEMORY_KB(name, sample) do { \ | 216 #define UMA_HISTOGRAM_MEMORY_KB(name, sample) do { \ |
| 201 static Histogram counter((name), 1000, 500000, 50); \ | 217 static Histogram counter((name), 1000, 500000, 50); \ |
| 202 counter.SetFlags(kUmaTargetedHistogramFlag); \ | 218 counter.SetFlags(kUmaTargetedHistogramFlag); \ |
| 203 counter.Add(sample); \ | 219 counter.Add(sample); \ |
| 204 } while (0) | 220 } while (0) |
| 205 | 221 |
| 206 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) do { \ | 222 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) do { \ |
| 207 static Histogram counter((name), 1, 1000, 50); \ | 223 static Histogram counter((name), 1, 1000, 50); \ |
| 208 counter.SetFlags(kUmaTargetedHistogramFlag); \ | 224 counter.SetFlags(kUmaTargetedHistogramFlag); \ |
| 209 counter.Add(sample); \ | 225 counter.Add(sample); \ |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 // lock protects access to the above map. | 579 // lock protects access to the above map. |
| 564 static Lock* lock_; | 580 static Lock* lock_; |
| 565 | 581 |
| 566 // Dump all known histograms to log. | 582 // Dump all known histograms to log. |
| 567 static bool dump_on_exit_; | 583 static bool dump_on_exit_; |
| 568 | 584 |
| 569 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 585 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
| 570 }; | 586 }; |
| 571 | 587 |
| 572 #endif // BASE_HISTOGRAM_H_ | 588 #endif // BASE_HISTOGRAM_H_ |
| OLD | NEW |