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

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

Issue 1725233002: histogram_macros: Added some documentation explaining constant rule. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reword comment for clarity. Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 histogram_factory_get_invocation) \ 104 histogram_factory_get_invocation) \
105 do { \ 105 do { \
106 static base::subtle::AtomicWord atomic_histogram_pointer = 0; \ 106 static base::subtle::AtomicWord atomic_histogram_pointer = 0; \
107 HISTOGRAM_POINTER_USE(&atomic_histogram_pointer, constant_histogram_name, \ 107 HISTOGRAM_POINTER_USE(&atomic_histogram_pointer, constant_histogram_name, \
108 histogram_add_method_invocation, \ 108 histogram_add_method_invocation, \
109 histogram_factory_get_invocation); \ 109 histogram_factory_get_invocation); \
110 } while (0) 110 } while (0)
111 111
112 //------------------------------------------------------------------------------ 112 //------------------------------------------------------------------------------
113 // Provide easy general purpose histogram in a macro, just like stats counters. 113 // Provide easy general purpose histogram in a macro, just like stats counters.
114 // The first four macros use 50 buckets. 114 // Most of these macros use 50 buckets, but check the definition for details.
115 //
116 // All of these macros must be called with |name| as a runtime constant --- it
117 // doesn't have to literally be a constant, but it must be the same string on
118 // all calls from a particular call site. If this rule is violated,
119 // STATIC_HISTOGRAM_POINTER_BLOCK will DCHECK, and if DCHECKS are disabled, the
120 // data will be written to the wrong histogram.
115 121
116 #define LOCAL_HISTOGRAM_TIMES(name, sample) LOCAL_HISTOGRAM_CUSTOM_TIMES( \ 122 #define LOCAL_HISTOGRAM_TIMES(name, sample) LOCAL_HISTOGRAM_CUSTOM_TIMES( \
117 name, sample, base::TimeDelta::FromMilliseconds(1), \ 123 name, sample, base::TimeDelta::FromMilliseconds(1), \
118 base::TimeDelta::FromSeconds(10), 50) 124 base::TimeDelta::FromSeconds(10), 50)
119 125
120 // For folks that need real specific times, use this to select a precise range 126 // For folks that need real specific times, use this to select a precise range
121 // of times you want plotted, and the number of buckets you want used. 127 // of times you want plotted, and the number of buckets you want used.
122 #define LOCAL_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \ 128 #define LOCAL_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \
123 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddTime(sample), \ 129 STATIC_HISTOGRAM_POINTER_BLOCK(name, AddTime(sample), \
124 base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \ 130 base::Histogram::FactoryTimeGet(name, min, max, bucket_count, \
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \ 289 UMA_HISTOGRAM_LONG_TIMES_100(name, elapsed); \
284 } else { \ 290 } else { \
285 UMA_HISTOGRAM_TIMES(name, elapsed); \ 291 UMA_HISTOGRAM_TIMES(name, elapsed); \
286 } \ 292 } \
287 } \ 293 } \
288 private: \ 294 private: \
289 base::TimeTicks constructed_; \ 295 base::TimeTicks constructed_; \
290 } scoped_histogram_timer_##key 296 } scoped_histogram_timer_##key
291 297
292 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ 298 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698