• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_METRICS_HISTOGRAM_MACROS_LOCAL_H_
6 #define BASE_METRICS_HISTOGRAM_MACROS_LOCAL_H_
7 
8 #include "base/logging.h"
9 #include "base/metrics/histogram.h"
10 #include "base/metrics/histogram_macros_internal.h"
11 #include "base/time/time.h"
12 
13 // TODO(rkaplow): Migrate all LOCAL_* usage within Chromium to include this
14 // file instead of the histogram_macros.h file.
15 
16 //------------------------------------------------------------------------------
17 // Enumeration histograms.
18 //
19 // For usage details, see the equivalents in histogram_macros.h.
20 
21 #define LOCAL_HISTOGRAM_ENUMERATION(name, ...)                          \
22   CR_EXPAND_ARG(INTERNAL_UMA_HISTOGRAM_ENUMERATION_GET_MACRO(           \
23       __VA_ARGS__, INTERNAL_UMA_HISTOGRAM_ENUMERATION_SPECIFY_BOUNDARY, \
24       INTERNAL_UMA_HISTOGRAM_ENUMERATION_DEDUCE_BOUNDARY)(              \
25       name, __VA_ARGS__, base::HistogramBase::kNoFlags))
26 
27 #define LOCAL_HISTOGRAM_BOOLEAN(name, sample)                                  \
28     STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample),                   \
29         base::BooleanHistogram::FactoryGet(name, base::Histogram::kNoFlags))
30 
31 //------------------------------------------------------------------------------
32 // Percentage histograms.
33 //
34 // For usage details, see the equivalents in histogram_macros.h
35 
36 #define LOCAL_HISTOGRAM_PERCENTAGE(name, under_one_hundred)                    \
37     LOCAL_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101)
38 
39 //------------------------------------------------------------------------------
40 // Count histograms. These are used for collecting numeric data. Note that we
41 // have macros for more specialized use cases below (memory, time, percentages).
42 // For usage details, see the equivalents in histogram_macros.h.
43 
44 #define LOCAL_HISTOGRAM_COUNTS_100(name, sample)                               \
45     LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 100, 50)
46 
47 #define LOCAL_HISTOGRAM_COUNTS_10000(name, sample)                             \
48     LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 10000, 50)
49 
50 #define LOCAL_HISTOGRAM_COUNTS_1000000(name, sample)                           \
51     LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000000, 50)
52 
53 #define LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count)    \
54     INTERNAL_HISTOGRAM_CUSTOM_COUNTS_WITH_FLAG(                                \
55         name, sample, min, max, bucket_count, base::HistogramBase::kNoFlags)
56 
57 //------------------------------------------------------------------------------
58 // Timing histograms. These are used for collecting timing data (generally
59 // latencies).
60 //
61 // For usage details, see the equivalents in histogram_macros.h.
62 
63 #define LOCAL_HISTOGRAM_TIMES(name, sample) LOCAL_HISTOGRAM_CUSTOM_TIMES(      \
64     name, sample, base::TimeDelta::FromMilliseconds(1),                        \
65     base::TimeDelta::FromSeconds(10), 50)
66 
67 #define LOCAL_HISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \
68   STATIC_HISTOGRAM_POINTER_BLOCK(                                          \
69       name, AddTimeMillisecondsGranularity(sample),                        \
70       base::Histogram::FactoryTimeGet(name, min, max, bucket_count,        \
71                                       base::HistogramBase::kNoFlags))
72 
73 //------------------------------------------------------------------------------
74 // Memory histograms.
75 //
76 // For usage details, see the equivalents in histogram_macros.h.
77 
78 #define LOCAL_HISTOGRAM_MEMORY_KB(name, sample) LOCAL_HISTOGRAM_CUSTOM_COUNTS( \
79     name, sample, 1000, 500000, 50)
80 
81 //------------------------------------------------------------------------------
82 // Deprecated histograms. Not recommended for current use.
83 
84 // TODO(rkaplow): See if we can clean up this macro and usage.
85 // Legacy non-explicit version. We suggest using LOCAL_HISTOGRAM_COUNTS_1000000
86 // instead.
87 #define LOCAL_HISTOGRAM_COUNTS(name, sample)                                   \
88     LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000000, 50)
89 
90 #endif  // BASE_METRICS_HISTOGRAM_MACROS_LOCAL_H_
91