| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_PERCENTAGE(name, under_one_hundred) do { \ | 66 #define HISTOGRAM_PERCENTAGE(name, under_one_hundred) do { \ |
| 67 static LinearHistogram counter((name), 1, 100, 101); \ | 67 static LinearHistogram counter((name), 1, 100, 101); \ |
| 68 counter.Add(under_one_hundred); \ | 68 counter.Add(under_one_hundred); \ |
| 69 } while (0) | 69 } while (0) |
| 70 | 70 |
| 71 // For folks that need real specific times, use this, but you'll only get | 71 // For folks that need real specific times, use this to select a precise range |
| 72 // samples that are in the range (overly large samples are discarded). | 72 // 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 { \ |
| 74 static Histogram counter((name), min, max, bucket_count); \ |
| 75 counter.AddTime(sample); \ |
| 76 } while (0) |
| 77 |
| 78 // DO NOT USE THIS. It is being phased out, in favor of HISTOGRAM_CUSTOM_TIMES. |
| 73 #define HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ | 79 #define HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ |
| 74 static Histogram counter((name), min, max, bucket_count); \ | 80 static Histogram counter((name), min, max, bucket_count); \ |
| 75 if ((sample) < (max)) counter.AddTime(sample); \ | 81 if ((sample) < (max)) counter.AddTime(sample); \ |
| 76 } while (0) | 82 } while (0) |
| 77 | 83 |
| 78 //------------------------------------------------------------------------------ | 84 //------------------------------------------------------------------------------ |
| 79 // This macro set is for a histogram that can support both addition and removal | 85 // This macro set is for a histogram that can support both addition and removal |
| 80 // of samples. It should be used to render the accumulated asset allocation | 86 // of samples. It should be used to render the accumulated asset allocation |
| 81 // of some samples. For example, it can sample memory allocation sizes, and | 87 // of some samples. For example, it can sample memory allocation sizes, and |
| 82 // memory releases (as negative samples). | 88 // memory releases (as negative samples). |
| (...skipping 18 matching lines...) Expand all Loading... |
| 101 //------------------------------------------------------------------------------ | 107 //------------------------------------------------------------------------------ |
| 102 // Define Debug vs non-debug flavors of macros. | 108 // Define Debug vs non-debug flavors of macros. |
| 103 #ifndef NDEBUG | 109 #ifndef NDEBUG |
| 104 | 110 |
| 105 #define DHISTOGRAM_TIMES(name, sample) HISTOGRAM_TIMES(name, sample) | 111 #define DHISTOGRAM_TIMES(name, sample) HISTOGRAM_TIMES(name, sample) |
| 106 #define DHISTOGRAM_COUNTS(name, sample) HISTOGRAM_COUNTS(name, sample) | 112 #define DHISTOGRAM_COUNTS(name, sample) HISTOGRAM_COUNTS(name, sample) |
| 107 #define DASSET_HISTOGRAM_COUNTS(name, sample) ASSET_HISTOGRAM_COUNTS(name, \ | 113 #define DASSET_HISTOGRAM_COUNTS(name, sample) ASSET_HISTOGRAM_COUNTS(name, \ |
| 108 sample) | 114 sample) |
| 109 #define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) HISTOGRAM_PERCENTAGE(\ | 115 #define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) HISTOGRAM_PERCENTAGE(\ |
| 110 name, under_one_hundred) | 116 name, under_one_hundred) |
| 117 #define DHISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ |
| 118 HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) |
| 111 #define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \ | 119 #define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \ |
| 112 HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) | 120 HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) |
| 113 | 121 |
| 114 #else // NDEBUG | 122 #else // NDEBUG |
| 115 | 123 |
| 116 #define DHISTOGRAM_TIMES(name, sample) do {} while (0) | 124 #define DHISTOGRAM_TIMES(name, sample) do {} while (0) |
| 117 #define DHISTOGRAM_COUNTS(name, sample) do {} while (0) | 125 #define DHISTOGRAM_COUNTS(name, sample) do {} while (0) |
| 118 #define DASSET_HISTOGRAM_COUNTS(name, sample) do {} while (0) | 126 #define DASSET_HISTOGRAM_COUNTS(name, sample) do {} while (0) |
| 119 #define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) do {} while (0) | 127 #define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) do {} while (0) |
| 128 #define DHISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ |
| 129 do {} while (0) |
| 120 #define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \ | 130 #define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \ |
| 121 do {} while (0) | 131 do {} while (0) |
| 122 | 132 |
| 123 #endif // NDEBUG | 133 #endif // NDEBUG |
| 124 | 134 |
| 125 //------------------------------------------------------------------------------ | 135 //------------------------------------------------------------------------------ |
| 126 // The following macros provide typical usage scenarios for callers that wish | 136 // The following macros provide typical usage scenarios for callers that wish |
| 127 // to record histogram data, and have the data submitted/uploaded via UMA. | 137 // to record histogram data, and have the data submitted/uploaded via UMA. |
| 128 // Not all systems support such UMA, but if they do, the following macros | 138 // Not all systems support such UMA, but if they do, the following macros |
| 129 // should work with the service. | 139 // should work with the service. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 150 } while (0) | 160 } while (0) |
| 151 | 161 |
| 152 // Use this macro when times can routinely be much longer than 10 seconds. | 162 // Use this macro when times can routinely be much longer than 10 seconds. |
| 153 #define UMA_HISTOGRAM_LONG_TIMES(name, sample) do { \ | 163 #define UMA_HISTOGRAM_LONG_TIMES(name, sample) do { \ |
| 154 static Histogram counter((name), base::TimeDelta::FromMilliseconds(1), \ | 164 static Histogram counter((name), base::TimeDelta::FromMilliseconds(1), \ |
| 155 base::TimeDelta::FromHours(1), 50); \ | 165 base::TimeDelta::FromHours(1), 50); \ |
| 156 counter.SetFlags(kUmaTargetedHistogramFlag); \ | 166 counter.SetFlags(kUmaTargetedHistogramFlag); \ |
| 157 counter.AddTime(sample); \ | 167 counter.AddTime(sample); \ |
| 158 } while (0) | 168 } while (0) |
| 159 | 169 |
| 170 #define UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) do { \ |
| 171 static Histogram counter((name), min, max, bucket_count); \ |
| 172 counter.SetFlags(kUmaTargetedHistogramFlag); \ |
| 173 counter.AddTime(sample); \ |
| 174 } while (0) |
| 175 |
| 160 #define UMA_HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ | 176 #define UMA_HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ |
| 161 static Histogram counter((name), min, max, bucket_count); \ | 177 static Histogram counter((name), min, max, bucket_count); \ |
| 162 counter.SetFlags(kUmaTargetedHistogramFlag); \ | 178 counter.SetFlags(kUmaTargetedHistogramFlag); \ |
| 163 if ((sample) < (max)) counter.AddTime(sample); \ | 179 if ((sample) < (max)) counter.AddTime(sample); \ |
| 164 } while (0) | 180 } while (0) |
| 165 | 181 |
| 166 #define UMA_HISTOGRAM_COUNTS(name, sample) do { \ | 182 #define UMA_HISTOGRAM_COUNTS(name, sample) do { \ |
| 167 static Histogram counter((name), 1, 1000000, 50); \ | 183 static Histogram counter((name), 1, 1000000, 50); \ |
| 168 counter.SetFlags(kUmaTargetedHistogramFlag); \ | 184 counter.SetFlags(kUmaTargetedHistogramFlag); \ |
| 169 counter.Add(sample); \ | 185 counter.Add(sample); \ |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 // lock protects access to the above map. | 563 // lock protects access to the above map. |
| 548 static Lock* lock_; | 564 static Lock* lock_; |
| 549 | 565 |
| 550 // Dump all known histograms to log. | 566 // Dump all known histograms to log. |
| 551 static bool dump_on_exit_; | 567 static bool dump_on_exit_; |
| 552 | 568 |
| 553 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 569 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
| 554 }; | 570 }; |
| 555 | 571 |
| 556 #endif // BASE_HISTOGRAM_H_ | 572 #endif // BASE_HISTOGRAM_H_ |
| OLD | NEW |