OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef BASE_METRICS_HISTOGRAM_MACROS_H_ | 5 #ifndef BASE_METRICS_HISTOGRAM_MACROS_H_ |
6 #define BASE_METRICS_HISTOGRAM_MACROS_H_ | 6 #define BASE_METRICS_HISTOGRAM_MACROS_H_ |
7 | 7 |
8 #include "base/atomicops.h" | 8 #include "base/atomicops.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } while (0); | 61 } while (0); |
62 */ | 62 */ |
63 | 63 |
64 // The above pattern is repeated in several macros. The only elements that | 64 // The above pattern is repeated in several macros. The only elements that |
65 // vary are the invocation of the Add(sample) vs AddTime(sample), and the choice | 65 // vary are the invocation of the Add(sample) vs AddTime(sample), and the choice |
66 // of which FactoryGet method to use. The different FactoryGet methods have | 66 // of which FactoryGet method to use. The different FactoryGet methods have |
67 // various argument lists, so the function with its argument list is provided as | 67 // various argument lists, so the function with its argument list is provided as |
68 // a macro argument here. The name is only used in a DCHECK, to assure that | 68 // a macro argument here. The name is only used in a DCHECK, to assure that |
69 // callers don't try to vary the name of the histogram (which would tend to be | 69 // callers don't try to vary the name of the histogram (which would tend to be |
70 // ignored by the one-time initialization of the histogtram_pointer). | 70 // ignored by the one-time initialization of the histogtram_pointer). |
71 #define STATIC_HISTOGRAM_POINTER_BLOCK(constant_histogram_name, \ | 71 #define STATIC_HISTOGRAM_POINTER_BLOCK(constant_histogram_name, \ |
72 histogram_add_method_invocation, \ | 72 histogram_add_method_invocation, \ |
73 histogram_factory_get_invocation) \ | 73 histogram_factory_get_invocation) \ |
74 do { \ | 74 do { \ |
75 static base::subtle::AtomicWord atomic_histogram_pointer = 0; \ | 75 static base::subtle::AtomicWord atomic_histogram_pointer = 0; \ |
76 base::HistogramBase* histogram_pointer( \ | 76 base::HistogramBase* histogram_pointer( \ |
77 reinterpret_cast<base::HistogramBase*>( \ | 77 reinterpret_cast<base::HistogramBase*>( \ |
78 base::subtle::Acquire_Load(&atomic_histogram_pointer))); \ | 78 base::subtle::Acquire_Load(&atomic_histogram_pointer))); \ |
79 if (!histogram_pointer) { \ | 79 if (!histogram_pointer) { \ |
80 histogram_pointer = histogram_factory_get_invocation; \ | 80 histogram_pointer = histogram_factory_get_invocation; \ |
81 base::subtle::Release_Store(&atomic_histogram_pointer, \ | 81 base::subtle::Release_Store( \ |
| 82 &atomic_histogram_pointer, \ |
82 reinterpret_cast<base::subtle::AtomicWord>(histogram_pointer)); \ | 83 reinterpret_cast<base::subtle::AtomicWord>(histogram_pointer)); \ |
83 } \ | 84 } \ |
84 if (DCHECK_IS_ON) \ | 85 if (DCHECK_IS_ON()) \ |
85 histogram_pointer->CheckName(constant_histogram_name); \ | 86 histogram_pointer->CheckName(constant_histogram_name); \ |
86 histogram_pointer->histogram_add_method_invocation; \ | 87 histogram_pointer->histogram_add_method_invocation; \ |
87 } while (0) | 88 } while (0) |
88 | 89 |
89 | |
90 //------------------------------------------------------------------------------ | 90 //------------------------------------------------------------------------------ |
91 // Provide easy general purpose histogram in a macro, just like stats counters. | 91 // Provide easy general purpose histogram in a macro, just like stats counters. |
92 // The first four macros use 50 buckets. | 92 // The first four macros use 50 buckets. |
93 | 93 |
94 #define LOCAL_HISTOGRAM_TIMES(name, sample) LOCAL_HISTOGRAM_CUSTOM_TIMES( \ | 94 #define LOCAL_HISTOGRAM_TIMES(name, sample) LOCAL_HISTOGRAM_CUSTOM_TIMES( \ |
95 name, sample, base::TimeDelta::FromMilliseconds(1), \ | 95 name, sample, base::TimeDelta::FromMilliseconds(1), \ |
96 base::TimeDelta::FromSeconds(10), 50) | 96 base::TimeDelta::FromSeconds(10), 50) |
97 | 97 |
98 // For folks that need real specific times, use this to select a precise range | 98 // For folks that need real specific times, use this to select a precise range |
99 // of times you want plotted, and the number of buckets you want used. | 99 // of times you want plotted, and the number of buckets you want used. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ | 223 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, boundary_value) \ |
224 HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary_value, \ | 224 HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, boundary_value, \ |
225 base::HistogramBase::kUmaStabilityHistogramFlag) | 225 base::HistogramBase::kUmaStabilityHistogramFlag) |
226 | 226 |
227 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ | 227 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ |
228 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ | 228 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ |
229 base::CustomHistogram::FactoryGet(name, custom_ranges, \ | 229 base::CustomHistogram::FactoryGet(name, custom_ranges, \ |
230 base::HistogramBase::kUmaTargetedHistogramFlag)) | 230 base::HistogramBase::kUmaTargetedHistogramFlag)) |
231 | 231 |
232 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ | 232 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ |
OLD | NEW |