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

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

Issue 2373523003: Clean up sparse_histogram.h header (Closed)
Patch Set: Add additional file in depot which depend on sparse_histogram.h Created 4 years, 2 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 | « base/files/file_win.cc ('k') | base/metrics/histogram_macros_internal.h » ('j') | 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/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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 12
13 // TODO(nikunjb): Move sparse macros to this file.
14 // UMA_HISTOGRAM_SPARSE_SLOWLY is defined in sparse_histogram.h as it has
15 // different #include dependencies.
16
17 // TODO(rkaplow): Link to proper documentation on metric creation once we have 13 // TODO(rkaplow): Link to proper documentation on metric creation once we have
18 // it in a good state. 14 // it in a good state.
19 15
20 // All of these macros must be called with |name| as a runtime constant - it 16 // All of these macros must be called with |name| as a runtime constant - it
21 // doesn't have to literally be a constant, but it must be the same string on 17 // doesn't have to literally be a constant, but it must be the same string on
22 // all calls from a particular call site. If this rule is violated, it is 18 // all calls from a particular call site. If this rule is violated, it is
23 // possible the data will be written to the wrong histogram. 19 // possible the data will be written to the wrong histogram.
24 20
25 //------------------------------------------------------------------------------ 21 //------------------------------------------------------------------------------
26 // Enumeration histograms. 22 // Enumeration histograms.
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 bucket_count) \ 217 bucket_count) \
222 INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \ 218 INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \
223 name, sample, min, max, bucket_count, \ 219 name, sample, min, max, bucket_count, \
224 base::HistogramBase::kUmaStabilityHistogramFlag) 220 base::HistogramBase::kUmaStabilityHistogramFlag)
225 221
226 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, enum_max) \ 222 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, enum_max) \
227 INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \ 223 INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \
228 name, sample, enum_max, \ 224 name, sample, enum_max, \
229 base::HistogramBase::kUmaStabilityHistogramFlag) 225 base::HistogramBase::kUmaStabilityHistogramFlag)
230 226
227 // Sparse histograms are well suited for recording counts of exact sample values
rkaplow 2016/09/30 14:55:00 Can you keep the formatting I added in the rest of
nikunjb1 2016/10/03 22:25:41 Done.
228 // that are sparsely distributed over a large range.
229 //
230 // The implementation uses a lock and a map, whereas other histogram types use a
rkaplow 2016/09/30 14:55:00 I think some of this technical detail could be red
nikunjb1 2016/10/03 22:25:41 Done. Moved implementation comments to internals.
231 // vector and no lock. It is thus more costly to add values to, and each value
232 // stored has more overhead, compared to the other histogram types. However it
233 // may be more efficient in memory if the total number of sample values is small
234 // compared to the range of their values.
235 //
236 // UMA_HISTOGRAM_ENUMERATION would be better suited for a smaller range of
rkaplow 2016/09/30 14:55:00 Don't need to document ENUM here I think. If we wa
nikunjb1 2016/10/03 22:25:41 Done.
237 // enumerations that are (nearly) contiguous. Also for code that is expected to
238 // run often or in a tight loop.
239 //
240 // UMA_HISTOGRAM_SPARSE_SLOWLY is good for sparsely distributed and or
241 // infrequently recorded values.
242 //
243 // For instance, Sqlite.Version.* are SPARSE because for any given database,
244 // there's going to be exactly one version logged, meaning no gain to having a
245 // pre-allocated vector of slots once the fleet gets to version 4 or 5 or 10.
rkaplow 2016/09/30 14:55:00 I'm not even sure what this comment means when it
nikunjb1 2016/10/03 22:25:42 Done. Added clarification.
246 // Likewise Sqlite.Error.* are SPARSE, because most databases generate few or no
247 // errors and there are large gaps in the set of possible errors.
248 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \
249 INTERNAL_HISTOGRAM_SPARSE_SLOWLY(name, sample)
231 250
232 //------------------------------------------------------------------------------ 251 //------------------------------------------------------------------------------
233 // Deprecated histogram macros. Not recommended for current use. 252 // Deprecated histogram macros. Not recommended for current use.
234 253
235 // Legacy name for UMA_HISTOGRAM_COUNTS_1M. Suggest using explicit naming 254 // Legacy name for UMA_HISTOGRAM_COUNTS_1M. Suggest using explicit naming
236 // and not using this macro going forward. 255 // and not using this macro going forward.
237 #define UMA_HISTOGRAM_COUNTS(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ 256 #define UMA_HISTOGRAM_COUNTS(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \
238 name, sample, 1, 1000000, 50) 257 name, sample, 1, 1000000, 50)
239 258
240 // MB-granularity memory metric. This has a short max (1G). 259 // MB-granularity memory metric. This has a short max (1G).
241 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) \ 260 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) \
242 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000, 50) 261 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000, 50)
243 262
244 // For an enum with customized range. In general, sparse histograms should be 263 // For an enum with customized range. In general, sparse histograms should be
245 // used instead. 264 // used instead.
246 // Samples should be one of the std::vector<int> list provided via 265 // Samples should be one of the std::vector<int> list provided via
247 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the 266 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the
248 // requirement of |custom_ranges|. You can use the helper function 267 // requirement of |custom_ranges|. You can use the helper function
249 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid 268 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid
250 // sample values to a std::vector<int>. 269 // sample values to a std::vector<int>.
251 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ 270 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \
252 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ 271 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \
253 base::CustomHistogram::FactoryGet(name, custom_ranges, \ 272 base::CustomHistogram::FactoryGet(name, custom_ranges, \
254 base::HistogramBase::kUmaTargetedHistogramFlag)) 273 base::HistogramBase::kUmaTargetedHistogramFlag))
255 274
256 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ 275 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_
OLDNEW
« no previous file with comments | « base/files/file_win.cc ('k') | base/metrics/histogram_macros_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698