Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: base/metrics/histogram_macros.h

Issue 2776853002: Make UMA_HISTOGRAM_ENUMERATION work with scoped enums. (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/metrics/histogram_macros_internal.h" 9 #include "base/metrics/histogram_macros_internal.h"
10 #include "base/metrics/histogram_macros_local.h" 10 #include "base/metrics/histogram_macros_local.h"
(...skipping 23 matching lines...) Expand all
34 // You should be defining an associated Enum, and the input sample should be 34 // You should be defining an associated Enum, and the input sample should be
35 // an element of the Enum. 35 // an element of the Enum.
36 // All of these macros must be called with |name| as a runtime constant. 36 // All of these macros must be called with |name| as a runtime constant.
37 37
38 // Sample usage: 38 // Sample usage:
39 // UMA_HISTOGRAM_ENUMERATION("My.Enumeration", VALUE, EVENT_MAX_VALUE); 39 // UMA_HISTOGRAM_ENUMERATION("My.Enumeration", VALUE, EVENT_MAX_VALUE);
40 // New Enum values can be added, but existing enums must never be renumbered or 40 // New Enum values can be added, but existing enums must never be renumbered or
41 // delete and reused. The value in |sample| must be strictly less than 41 // delete and reused. The value in |sample| must be strictly less than
42 // |enum_max|. 42 // |enum_max|.
43 43
44 #define UMA_HISTOGRAM_ENUMERATION(name, sample, enum_max) \ 44 #define UMA_HISTOGRAM_ENUMERATION(name, sample, enum_max) \
45 INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \ 45 INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \
46 name, sample, enum_max, \ 46 name, sample, enum_max, base::HistogramBase::kUmaTargetedHistogramFlag)
47 base::HistogramBase::kUmaTargetedHistogramFlag)
48 47
49 // Histogram for boolean values. 48 // Histogram for boolean values.
50 49
51 // Sample usage: 50 // Sample usage:
52 // UMA_HISTOGRAM_BOOLEAN("Histogram.Boolean", bool); 51 // UMA_HISTOGRAM_BOOLEAN("Histogram.Boolean", bool);
53 #define UMA_HISTOGRAM_BOOLEAN(name, sample) \ 52 #define UMA_HISTOGRAM_BOOLEAN(name, sample) \
54 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \ 53 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \
55 base::BooleanHistogram::FactoryGet(name, \ 54 base::BooleanHistogram::FactoryGet(name, \
56 base::HistogramBase::kUmaTargetedHistogramFlag)) 55 base::HistogramBase::kUmaTargetedHistogramFlag))
57 56
58 //------------------------------------------------------------------------------ 57 //------------------------------------------------------------------------------
59 // Linear histograms. 58 // Linear histograms.
60 59
61 // All of these macros must be called with |name| as a runtime constant. 60 // All of these macros must be called with |name| as a runtime constant.
62 61
63 // Used for capturing integer data with a linear bucketing scheme. This can be 62 // Used for capturing integer data with a linear bucketing scheme. This can be
64 // used when you want the exact value of some small numeric count, with a max of 63 // used when you want the exact value of some small numeric count, with a max of
65 // 100 or less. If you need to capture a range of greater than 100, we recommend 64 // 100 or less. If you need to capture a range of greater than 100, we recommend
66 // the use of the COUNT histograms below. 65 // the use of the COUNT histograms below.
67 66
68 // Sample usage: 67 // Sample usage:
69 // UMA_HISTOGRAM_EXACT_LINEAR("Histogram.Linear", count, 10); 68 // UMA_HISTOGRAM_EXACT_LINEAR("Histogram.Linear", count, 10);
70 #define UMA_HISTOGRAM_EXACT_LINEAR(name, sample, value_max) \ 69 #define UMA_HISTOGRAM_EXACT_LINEAR(name, sample, value_max) \
71 UMA_HISTOGRAM_ENUMERATION(name, sample, value_max) 70 INTERNAL_HISTOGRAM_EXACT_LINEAR_WITH_FLAG( \
71 name, sample, value_max, base::HistogramBase::kUmaTargetedHistogramFlag)
72 72
73 // Used for capturing basic percentages. This will be 100 buckets of size 1. 73 // Used for capturing basic percentages. This will be 100 buckets of size 1.
74 74
75 // Sample usage: 75 // Sample usage:
76 // UMA_HISTOGRAM_PERCENTAGE("Histogram.Percent", percent_as_int); 76 // UMA_HISTOGRAM_PERCENTAGE("Histogram.Percent", percent_as_int);
77 #define UMA_HISTOGRAM_PERCENTAGE(name, percent_as_int) \ 77 #define UMA_HISTOGRAM_PERCENTAGE(name, percent_as_int) \
78 UMA_HISTOGRAM_ENUMERATION(name, percent_as_int, 101) 78 UMA_HISTOGRAM_EXACT_LINEAR(name, percent_as_int, 101)
79 79
80 //------------------------------------------------------------------------------ 80 //------------------------------------------------------------------------------
81 // Count histograms. These are used for collecting numeric data. Note that we 81 // Count histograms. These are used for collecting numeric data. Note that we
82 // have macros for more specialized use cases below (memory, time, percentages). 82 // have macros for more specialized use cases below (memory, time, percentages).
83 83
84 // The number suffixes here refer to the max size of the sample, i.e. COUNT_1000 84 // The number suffixes here refer to the max size of the sample, i.e. COUNT_1000
85 // will be able to collect samples of counts up to 1000. The default number of 85 // will be able to collect samples of counts up to 1000. The default number of
86 // buckets in all default macros is 50. We recommend erring on the side of too 86 // buckets in all default macros is 50. We recommend erring on the side of too
87 // large a range versus too short a range. 87 // large a range versus too short a range.
88 // These macros default to exponential histograms - i.e. the lengths of the 88 // These macros default to exponential histograms - i.e. the lengths of the
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the 306 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the
307 // requirement of |custom_ranges|. You can use the helper function 307 // requirement of |custom_ranges|. You can use the helper function
308 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid 308 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid
309 // sample values to a std::vector<int>. 309 // sample values to a std::vector<int>.
310 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ 310 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \
311 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ 311 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \
312 base::CustomHistogram::FactoryGet(name, custom_ranges, \ 312 base::CustomHistogram::FactoryGet(name, custom_ranges, \
313 base::HistogramBase::kUmaTargetedHistogramFlag)) 313 base::HistogramBase::kUmaTargetedHistogramFlag))
314 314
315 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ 315 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698