| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 DCHECK_EQ(name, counter->histogram_name()); \ | 63 DCHECK_EQ(name, counter->histogram_name()); \ |
| 64 counter->Add(sample); \ | 64 counter->Add(sample); \ |
| 65 } while (0) | 65 } while (0) |
| 66 | 66 |
| 67 #define HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ | 67 #define HISTOGRAM_PERCENTAGE(name, under_one_hundred) \ |
| 68 HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) | 68 HISTOGRAM_ENUMERATION(name, under_one_hundred, 101) |
| 69 | 69 |
| 70 // For folks that need real specific times, use this to select a precise range | 70 // For folks that need real specific times, use this to select a precise range |
| 71 // of times you want plotted, and the number of buckets you want used. | 71 // of times you want plotted, and the number of buckets you want used. |
| 72 #define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) do { \ | 72 #define HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) do { \ |
| 73 static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \ | 73 static scoped_refptr<Histogram> counter = Histogram::FactoryTimeGet( \ |
| 74 name, min, max, bucket_count, Histogram::kNoFlags); \ | 74 name, min, max, bucket_count, Histogram::kNoFlags); \ |
| 75 DCHECK_EQ(name, counter->histogram_name()); \ | 75 DCHECK_EQ(name, counter->histogram_name()); \ |
| 76 counter->AddTime(sample); \ | 76 counter->AddTime(sample); \ |
| 77 } while (0) | 77 } while (0) |
| 78 | 78 |
| 79 // DO NOT USE THIS. It is being phased out, in favor of HISTOGRAM_CUSTOM_TIMES. | 79 // DO NOT USE THIS. It is being phased out, in favor of HISTOGRAM_CUSTOM_TIMES. |
| 80 #define HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ | 80 #define HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ |
| 81 static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \ | 81 static scoped_refptr<Histogram> counter = Histogram::FactoryTimeGet( \ |
| 82 name, min, max, bucket_count, Histogram::kNoFlags); \ | 82 name, min, max, bucket_count, Histogram::kNoFlags); \ |
| 83 DCHECK_EQ(name, counter->histogram_name()); \ | 83 DCHECK_EQ(name, counter->histogram_name()); \ |
| 84 if ((sample) < (max)) counter->AddTime(sample); \ | 84 if ((sample) < (max)) counter->AddTime(sample); \ |
| 85 } while (0) | 85 } while (0) |
| 86 | 86 |
| 87 // Support histograming of an enumerated value. The samples should always be | 87 // Support histograming of an enumerated value. The samples should always be |
| 88 // less than boundary_value. | 88 // less than boundary_value. |
| 89 | 89 |
| 90 #define HISTOGRAM_ENUMERATION(name, sample, boundary_value) do { \ | 90 #define HISTOGRAM_ENUMERATION(name, sample, boundary_value) do { \ |
| 91 static scoped_refptr<Histogram> counter = LinearHistogram::FactoryGet( \ | 91 static scoped_refptr<Histogram> counter = LinearHistogram::FactoryGet( \ |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 #define UMA_HISTOGRAM_MEDIUM_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \ | 151 #define UMA_HISTOGRAM_MEDIUM_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \ |
| 152 name, sample, base::TimeDelta::FromMilliseconds(10), \ | 152 name, sample, base::TimeDelta::FromMilliseconds(10), \ |
| 153 base::TimeDelta::FromMinutes(3), 50) | 153 base::TimeDelta::FromMinutes(3), 50) |
| 154 | 154 |
| 155 // Use this macro when times can routinely be much longer than 10 seconds. | 155 // Use this macro when times can routinely be much longer than 10 seconds. |
| 156 #define UMA_HISTOGRAM_LONG_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \ | 156 #define UMA_HISTOGRAM_LONG_TIMES(name, sample) UMA_HISTOGRAM_CUSTOM_TIMES( \ |
| 157 name, sample, base::TimeDelta::FromMilliseconds(1), \ | 157 name, sample, base::TimeDelta::FromMilliseconds(1), \ |
| 158 base::TimeDelta::FromHours(1), 50) | 158 base::TimeDelta::FromHours(1), 50) |
| 159 | 159 |
| 160 #define UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) do { \ | 160 #define UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) do { \ |
| 161 static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \ | 161 static scoped_refptr<Histogram> counter = Histogram::FactoryTimeGet( \ |
| 162 name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \ | 162 name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \ |
| 163 DCHECK_EQ(name, counter->histogram_name()); \ | 163 DCHECK_EQ(name, counter->histogram_name()); \ |
| 164 counter->AddTime(sample); \ | 164 counter->AddTime(sample); \ |
| 165 } while (0) | 165 } while (0) |
| 166 | 166 |
| 167 // DO NOT USE THIS. It is being phased out, in favor of HISTOGRAM_CUSTOM_TIMES. | 167 // DO NOT USE THIS. It is being phased out, in favor of HISTOGRAM_CUSTOM_TIMES. |
| 168 #define UMA_HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ | 168 #define UMA_HISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) do { \ |
| 169 static scoped_refptr<Histogram> counter = Histogram::FactoryGet( \ | 169 static scoped_refptr<Histogram> counter = Histogram::FactoryTimeGet( \ |
| 170 name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \ | 170 name, min, max, bucket_count, Histogram::kUmaTargetedHistogramFlag); \ |
| 171 DCHECK_EQ(name, counter->histogram_name()); \ | 171 DCHECK_EQ(name, counter->histogram_name()); \ |
| 172 if ((sample) < (max)) counter->AddTime(sample); \ | 172 if ((sample) < (max)) counter->AddTime(sample); \ |
| 173 } while (0) | 173 } while (0) |
| 174 | 174 |
| 175 #define UMA_HISTOGRAM_COUNTS(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 175 #define UMA_HISTOGRAM_COUNTS(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 176 name, sample, 1, 1000000, 50) | 176 name, sample, 1, 1000000, 50) |
| 177 | 177 |
| 178 #define UMA_HISTOGRAM_COUNTS_100(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 178 #define UMA_HISTOGRAM_COUNTS_100(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ |
| 179 name, sample, 1, 100, 50) | 179 name, sample, 1, 100, 50) |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // Save simple stats locally. Note that this MIGHT get done in base class | 303 // Save simple stats locally. Note that this MIGHT get done in base class |
| 304 // without shared memory at some point. | 304 // without shared memory at some point. |
| 305 int64 sum_; // sum of samples. | 305 int64 sum_; // sum of samples. |
| 306 int64 square_sum_; // sum of squares of samples. | 306 int64 square_sum_; // sum of squares of samples. |
| 307 }; | 307 }; |
| 308 //---------------------------------------------------------------------------- | 308 //---------------------------------------------------------------------------- |
| 309 // minimum should start from 1. 0 is invalid as a minimum. 0 is an implicit | 309 // minimum should start from 1. 0 is invalid as a minimum. 0 is an implicit |
| 310 // default underflow bucket. | 310 // default underflow bucket. |
| 311 static scoped_refptr<Histogram> FactoryGet(const std::string& name, | 311 static scoped_refptr<Histogram> FactoryGet(const std::string& name, |
| 312 Sample minimum, Sample maximum, size_t bucket_count, Flags flags); | 312 Sample minimum, Sample maximum, size_t bucket_count, Flags flags); |
| 313 static scoped_refptr<Histogram> FactoryGet(const std::string& name, | 313 static scoped_refptr<Histogram> FactoryTimeGet(const std::string& name, |
| 314 base::TimeDelta minimum, base::TimeDelta maximum, size_t bucket_count, | 314 base::TimeDelta minimum, base::TimeDelta maximum, size_t bucket_count, |
| 315 Flags flags); | 315 Flags flags); |
| 316 | 316 |
| 317 void Add(int value); | 317 void Add(int value); |
| 318 | 318 |
| 319 // This method is an interface, used only by BooleanHistogram. | 319 // This method is an interface, used only by BooleanHistogram. |
| 320 virtual void AddBoolean(bool value) { DCHECK(false); } | 320 virtual void AddBoolean(bool value) { DCHECK(false); } |
| 321 | 321 |
| 322 // Accept a TimeDelta to increment. | 322 // Accept a TimeDelta to increment. |
| 323 void AddTime(base::TimeDelta time) { | 323 void AddTime(base::TimeDelta time) { |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 // lock protects access to the above map. | 627 // lock protects access to the above map. |
| 628 static Lock* lock_; | 628 static Lock* lock_; |
| 629 | 629 |
| 630 // Dump all known histograms to log. | 630 // Dump all known histograms to log. |
| 631 static bool dump_on_exit_; | 631 static bool dump_on_exit_; |
| 632 | 632 |
| 633 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 633 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
| 634 }; | 634 }; |
| 635 | 635 |
| 636 #endif // BASE_HISTOGRAM_H_ | 636 #endif // BASE_HISTOGRAM_H_ |
| OLD | NEW |