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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 #endif // NDEBUG | 95 #endif // NDEBUG |
96 | 96 |
97 //------------------------------------------------------------------------------ | 97 //------------------------------------------------------------------------------ |
98 // The following macros provide typical usage scenarios for callers that wish | 98 // The following macros provide typical usage scenarios for callers that wish |
99 // to record histogram data, and have the data submitted/uploaded via UMA. | 99 // to record histogram data, and have the data submitted/uploaded via UMA. |
100 // Not all systems support such UMA, but if they do, the following macros | 100 // Not all systems support such UMA, but if they do, the following macros |
101 // should work with the service. | 101 // should work with the service. |
102 | 102 |
103 static const int kUmaTargetedHistogramFlag = 0x1; | 103 static const int kUmaTargetedHistogramFlag = 0x1; |
104 | 104 |
105 #define UMA_HISTOGRAM_TIMES(name, sample) do { \ | 105 #define UMA_HISTOGRAM_TIMES(name, sample) do { \ |
Lincoln
2008/11/24 17:31:42
If the other macro describes a "medium" histogram
| |
106 static Histogram counter((name), base::TimeDelta::FromMilliseconds(1), \ | 106 static Histogram counter((name), base::TimeDelta::FromMilliseconds(1), \ |
107 base::TimeDelta::FromSeconds(10), 50); \ | 107 base::TimeDelta::FromSeconds(10), 50); \ |
108 counter.SetFlags(kUmaTargetedHistogramFlag); \ | 108 counter.SetFlags(kUmaTargetedHistogramFlag); \ |
109 counter.AddTime(sample); \ | 109 counter.AddTime(sample); \ |
110 } while (0) | 110 } while (0) |
111 | 111 |
112 #define UMA_HISTOGRAM_MEDIUM_TIMES(name, sample) do { \ | |
113 static Histogram counter((name), base::TimeDelta::FromMilliseconds(10), \ | |
114 base::TimeDelta::FromMinutes(3), 50); \ | |
115 counter.SetFlags(kUmaTargetedHistogramFlag); \ | |
116 counter.AddTime(sample); \ | |
117 } while (0) | |
118 | |
112 // Use this macro when times can routinely be much longer than 10 seconds. | 119 // Use this macro when times can routinely be much longer than 10 seconds. |
113 #define UMA_HISTOGRAM_LONG_TIMES(name, sample) do { \ | 120 #define UMA_HISTOGRAM_LONG_TIMES(name, sample) do { \ |
114 static Histogram counter((name), base::TimeDelta::FromMilliseconds(1), \ | 121 static Histogram counter((name), base::TimeDelta::FromMilliseconds(1), \ |
115 base::TimeDelta::FromHours(1), 50); \ | 122 base::TimeDelta::FromHours(1), 50); \ |
116 counter.SetFlags(kUmaTargetedHistogramFlag); \ | 123 counter.SetFlags(kUmaTargetedHistogramFlag); \ |
117 counter.AddTime(sample); \ | 124 counter.AddTime(sample); \ |
118 } while (0) | 125 } while (0) |
119 | 126 |
120 #define UMA_HISTOGRAM_COUNTS(name, sample) do { \ | 127 #define UMA_HISTOGRAM_COUNTS(name, sample) do { \ |
121 static Histogram counter((name), 1, 1000000, 50); \ | 128 static Histogram counter((name), 1, 1000000, 50); \ |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 Histogram(const wchar_t* name, Sample minimum, | 199 Histogram(const wchar_t* name, Sample minimum, |
193 Sample maximum, size_t bucket_count); | 200 Sample maximum, size_t bucket_count); |
194 Histogram(const wchar_t* name, base::TimeDelta minimum, | 201 Histogram(const wchar_t* name, base::TimeDelta minimum, |
195 base::TimeDelta maximum, size_t bucket_count); | 202 base::TimeDelta maximum, size_t bucket_count); |
196 virtual ~Histogram(); | 203 virtual ~Histogram(); |
197 | 204 |
198 // Hooks to override stats counter methods. This ensures that we gather all | 205 // Hooks to override stats counter methods. This ensures that we gather all |
199 // input the stats counter sees. | 206 // input the stats counter sees. |
200 virtual void Add(int value); | 207 virtual void Add(int value); |
201 | 208 |
202 // The following methods provide a graphical histogram displays. | 209 // The following methods provide graphical histogram displays. |
203 void WriteHTMLGraph(std::string* output) const; | 210 void WriteHTMLGraph(std::string* output) const; |
204 void WriteAscii(bool graph_it, const std::string& newline, | 211 void WriteAscii(bool graph_it, const std::string& newline, |
205 std::string* output) const; | 212 std::string* output) const; |
206 | 213 |
207 // Support generic flagging of Histograms. | 214 // Support generic flagging of Histograms. |
208 // 0x1 Currently used to mark this histogram to be recorded by UMA.. | 215 // 0x1 Currently used to mark this histogram to be recorded by UMA.. |
209 // 0x8000 means print ranges in hex. | 216 // 0x8000 means print ranges in hex. |
210 void SetFlags(int flags) { flags_ |= flags; } | 217 void SetFlags(int flags) { flags_ |= flags; } |
211 void ClearFlags(int flags) { flags_ &= ~flags; } | 218 void ClearFlags(int flags) { flags_ &= ~flags; } |
212 int flags() const { return flags_; } | 219 int flags() const { return flags_; } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 static Lock* lock_; | 443 static Lock* lock_; |
437 | 444 |
438 // Dump all known histograms to log. | 445 // Dump all known histograms to log. |
439 static bool dump_on_exit_; | 446 static bool dump_on_exit_; |
440 | 447 |
441 DISALLOW_EVIL_CONSTRUCTORS(StatisticsRecorder); | 448 DISALLOW_EVIL_CONSTRUCTORS(StatisticsRecorder); |
442 }; | 449 }; |
443 | 450 |
444 #endif // BASE_HISTOGRAM_H__ | 451 #endif // BASE_HISTOGRAM_H__ |
445 | 452 |
OLD | NEW |