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