blob: ccb0f85771874e60b4e86a6ed6dee98ba763f6b3 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2016 The Chromium Authors
rkaplowa1ee2052016-09-27 17:12:082// 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
rkaplowa1ee2052016-09-27 17:12:088#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
Daniel Chenga67dd552018-03-31 02:30:4620#define LOCAL_HISTOGRAM_ENUMERATION(name, ...) \
Avi Drissmanb00a9e7e2018-10-12 01:01:5621 INTERNAL_UMA_HISTOGRAM_ENUMERATION_GET_MACRO( \
Daniel Chenga67dd552018-03-31 02:30:4622 __VA_ARGS__, INTERNAL_UMA_HISTOGRAM_ENUMERATION_SPECIFY_BOUNDARY, \
Avi Drissmanb00a9e7e2018-10-12 01:01:5623 INTERNAL_UMA_HISTOGRAM_ENUMERATION_DEDUCE_BOUNDARY) \
24 (name, __VA_ARGS__, base::HistogramBase::kNoFlags)
rkaplowa1ee2052016-09-27 17:12:0825
Peter Kasting134ef9af2024-12-28 02:30:0926#define LOCAL_HISTOGRAM_BOOLEAN(name, sample) \
27 STATIC_HISTOGRAM_POINTER_BLOCK( \
28 name, AddBoolean(sample), \
29 base::BooleanHistogram::FactoryGet(name, base::Histogram::kNoFlags))
rkaplowa1ee2052016-09-27 17:12:0830
31//------------------------------------------------------------------------------
32// Percentage histograms.
33//
34// For usage details, see the equivalents in histogram_macros.h
35
Peter Kasting134ef9af2024-12-28 02:30:0936#define LOCAL_HISTOGRAM_PERCENTAGE(name, under_one_hundred) \
37 LOCAL_HISTOGRAM_ENUMERATION(name, under_one_hundred, 101)
rkaplowa1ee2052016-09-27 17:12:0838
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
Peter Kasting134ef9af2024-12-28 02:30:0944#define LOCAL_HISTOGRAM_COUNTS_100(name, sample) \
45 LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 100, 50)
rkaplowa1ee2052016-09-27 17:12:0846
Peter Kasting134ef9af2024-12-28 02:30:0947#define LOCAL_HISTOGRAM_COUNTS_10000(name, sample) \
48 LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 10000, 50)
rkaplowa1ee2052016-09-27 17:12:0849
Peter Kasting134ef9af2024-12-28 02:30:0950#define LOCAL_HISTOGRAM_COUNTS_1000000(name, sample) \
51 LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000000, 50)
rkaplowa1ee2052016-09-27 17:12:0852
Peter Kasting134ef9af2024-12-28 02:30:0953#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)
rkaplowa1ee2052016-09-27 17:12:0856
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
Peter Kastinge5a38ed2021-10-02 03:06:3563#define LOCAL_HISTOGRAM_TIMES(name, sample) \
64 LOCAL_HISTOGRAM_CUSTOM_TIMES(name, sample, base::Milliseconds(1), \
65 base::Seconds(10), 50)
rkaplowa1ee2052016-09-27 17:12:0866
Gabriel Charette5ec205882018-05-22 18:07:3167#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))
rkaplowa1ee2052016-09-27 17:12:0872
Vasiliy Telezhnikove7b3c7e2020-11-19 14:33:5573#define LOCAL_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(name, sample, min, max, \
74 bucket_count) \
75 STATIC_HISTOGRAM_POINTER_BLOCK( \
76 name, AddTimeMicrosecondsGranularity(sample), \
77 base::Histogram::FactoryMicrosecondsTimeGet( \
78 name, min, max, bucket_count, base::HistogramBase::kNoFlags))
rkaplowa1ee2052016-09-27 17:12:0879//------------------------------------------------------------------------------
80// Memory histograms.
81//
82// For usage details, see the equivalents in histogram_macros.h.
83
Peter Kasting134ef9af2024-12-28 02:30:0984#define LOCAL_HISTOGRAM_MEMORY_KB(name, sample) \
85 LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1000, 500000, 50)
rkaplowa1ee2052016-09-27 17:12:0886
87//------------------------------------------------------------------------------
88// Deprecated histograms. Not recommended for current use.
89
90// TODO(rkaplow): See if we can clean up this macro and usage.
91// Legacy non-explicit version. We suggest using LOCAL_HISTOGRAM_COUNTS_1000000
92// instead.
Peter Kasting134ef9af2024-12-28 02:30:0993#define LOCAL_HISTOGRAM_COUNTS(name, sample) \
94 LOCAL_HISTOGRAM_CUSTOM_COUNTS(name, sample, 1, 1000000, 50)
rkaplowa1ee2052016-09-27 17:12:0895
96#endif // BASE_METRICS_HISTOGRAM_MACROS_LOCAL_H_