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

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

Issue 2373523003: Clean up sparse_histogram.h header (Closed)
Patch Set: Rebase update on Oct 18 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
13 // Macros for efficient use of histograms. 14 // Macros for efficient use of histograms.
14 // 15 //
15 // For best practices on deciding when to emit to a histogram and what form 16 // For best practices on deciding when to emit to a histogram and what form
16 // the histogram should take, see 17 // the histogram should take, see
17 // https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histo grams/README.md 18 // https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histo grams/README.md
18 //
19 // TODO(nikunjb): Move sparse macros to this file.
20 //
21 // UMA_HISTOGRAM_SPARSE_SLOWLY is defined in sparse_histogram.h as it has
22 // different #include dependencies.
23 19
24 // TODO(rkaplow): Link to proper documentation on metric creation once we have 20 // TODO(rkaplow): Link to proper documentation on metric creation once we have
25 // it in a good state. 21 // it in a good state.
26 22
27 // All of these macros must be called with |name| as a runtime constant - it 23 // All of these macros must be called with |name| as a runtime constant - it
28 // doesn't have to literally be a constant, but it must be the same string on 24 // doesn't have to literally be a constant, but it must be the same string on
29 // all calls from a particular call site. If this rule is violated, it is 25 // all calls from a particular call site. If this rule is violated, it is
30 // possible the data will be written to the wrong histogram. 26 // possible the data will be written to the wrong histogram.
31 27
32 //------------------------------------------------------------------------------ 28 //------------------------------------------------------------------------------
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 bucket_count) \ 232 bucket_count) \
237 INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \ 233 INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG( \
238 name, sample, min, max, bucket_count, \ 234 name, sample, min, max, bucket_count, \
239 base::HistogramBase::kUmaStabilityHistogramFlag) 235 base::HistogramBase::kUmaStabilityHistogramFlag)
240 236
241 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, enum_max) \ 237 #define UMA_STABILITY_HISTOGRAM_ENUMERATION(name, sample, enum_max) \
242 INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \ 238 INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \
243 name, sample, enum_max, \ 239 name, sample, enum_max, \
244 base::HistogramBase::kUmaStabilityHistogramFlag) 240 base::HistogramBase::kUmaStabilityHistogramFlag)
245 241
242 //------------------------------------------------------------------------------
243 // Sparse histograms.
244
245 // Sparse histograms are well suited for recording counts of exact sample values
246 // that are sparsely distributed over a large range.
247 //
248 // UMA_HISTOGRAM_SPARSE_SLOWLY is good for sparsely distributed and/or
249 // infrequently recorded values since the implementation is slower
250 // and takes more memory.
251 //
252 // For instance, Sqlite.Version.* are sparse because for any given database,
253 // there's going to be exactly one version logged.
254 #define UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample) \
255 INTERNAL_HISTOGRAM_SPARSE_SLOWLY(name, sample)
246 256
247 //------------------------------------------------------------------------------ 257 //------------------------------------------------------------------------------
248 // Deprecated histogram macros. Not recommended for current use. 258 // Deprecated histogram macros. Not recommended for current use.
249 259
250 // Legacy name for UMA_HISTOGRAM_COUNTS_1M. Suggest using explicit naming 260 // Legacy name for UMA_HISTOGRAM_COUNTS_1M. Suggest using explicit naming
251 // and not using this macro going forward. 261 // and not using this macro going forward.
252 #define UMA_HISTOGRAM_COUNTS(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \ 262 #define UMA_HISTOGRAM_COUNTS(name, sample) UMA_HISTOGRAM_CUSTOM_COUNTS( \
253 name, sample, 1, 1000000, 50) 263 name, sample, 1, 1000000, 50)
254 264
255 // MB-granularity memory metric. This has a short max (1G). 265 // MB-granularity memory metric. This has a short max (1G).
256 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) \ 266 #define UMA_HISTOGRAM_MEMORY_MB(name, sample) \
257 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000, 50) 267 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000, 50)
258 268
259 // For an enum with customized range. In general, sparse histograms should be 269 // For an enum with customized range. In general, sparse histograms should be
260 // used instead. 270 // used instead.
261 // Samples should be one of the std::vector<int> list provided via 271 // Samples should be one of the std::vector<int> list provided via
262 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the 272 // |custom_ranges|. See comments above CustomRanges::FactoryGet about the
263 // requirement of |custom_ranges|. You can use the helper function 273 // requirement of |custom_ranges|. You can use the helper function
264 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid 274 // CustomHistogram::ArrayToCustomRanges to transform a C-style array of valid
265 // sample values to a std::vector<int>. 275 // sample values to a std::vector<int>.
266 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \ 276 #define UMA_HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \
267 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \ 277 STATIC_HISTOGRAM_POINTER_BLOCK(name, Add(sample), \
268 base::CustomHistogram::FactoryGet(name, custom_ranges, \ 278 base::CustomHistogram::FactoryGet(name, custom_ranges, \
269 base::HistogramBase::kUmaTargetedHistogramFlag)) 279 base::HistogramBase::kUmaTargetedHistogramFlag))
270 280
271 #endif // BASE_METRICS_HISTOGRAM_MACROS_H_ 281 #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