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

Side by Side Diff: base/metrics/histogram_functions.cc

Issue 2393493002: Expose macros from base/metrics/histogram_macros.h as functions (Closed)
Patch Set: Review comments Created 4 years, 1 month 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
OLDNEW
(Empty)
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 #include "base/metrics/histogram_functions.h"
6
7 #include "base/metrics/histogram.h"
8 #include "base/metrics/histogram_base.h"
9 #include "base/time/time.h"
10
11 namespace base {
12
13 void UmaHistogramBoolean(const std::string& name, bool sample) {
14 HistogramBase* histogram = BooleanHistogram::FactoryGet(
15 name, base::HistogramBase::kUmaTargetedHistogramFlag);
16 histogram->Add(sample);
17 }
18
19 void UmaHistogramExactLinear(const std::string& name,
20 int sample,
21 int value_max) {
22 HistogramBase* histogram =
23 LinearHistogram::FactoryGet(name, 1, value_max, value_max + 1,
24 HistogramBase::kUmaTargetedHistogramFlag);
25 histogram->Add(sample);
26 }
27
28 void UmaHistogramPercentage(const std::string& name, int percent) {
29 UmaHistogramExactLinear(name, percent, 100);
30 }
31
32 void UmaHistogramCustomCounts(const std::string& name,
33 int sample,
34 int min,
35 int max,
36 int buckets) {
37 HistogramBase* histogram = Histogram::FactoryGet(
38 name, min, max, buckets, HistogramBase::kUmaTargetedHistogramFlag);
39 histogram->Add(sample);
40 }
41
42 void UmaHistogramCounts100(const std::string& name, int sample) {
43 UmaHistogramCustomCounts(name, sample, 1, 100, 50);
44 }
45
46 void UmaHistogramCounts1000(const std::string& name, int sample) {
47 UmaHistogramCustomCounts(name, sample, 1, 1000, 50);
48 }
49
50 void UmaHistogramCounts10000(const std::string& name, int sample) {
51 UmaHistogramCustomCounts(name, sample, 1, 10000, 50);
52 }
53
54 void UmaHistogramCounts100000(const std::string& name, int sample) {
55 UmaHistogramCustomCounts(name, sample, 1, 100000, 50);
56 }
57
58 void UmaHistogramCounts1M(const std::string& name, int sample) {
59 UmaHistogramCustomCounts(name, sample, 1, 1000000, 50);
60 }
61
62 void UmaHistogramCounts10M(const std::string& name, int sample) {
63 UmaHistogramCustomCounts(name, sample, 1, 10000000, 50);
64 }
65
66 void UmaHistogramCustomTimes(const std::string& name,
67 TimeDelta sample,
68 TimeDelta min,
69 TimeDelta max,
70 int buckets) {
71 HistogramBase* histogram = Histogram::FactoryTimeGet(
72 name, min, max, buckets, HistogramBase::kUmaTargetedHistogramFlag);
73 histogram->AddTime(sample);
74 }
75
76 void UmaHistogramTimes(const std::string& name, TimeDelta sample) {
77 UmaHistogramCustomTimes(name, sample, TimeDelta::FromMilliseconds(1),
78 TimeDelta::FromSeconds(10), 50);
79 }
80
81 void UmaHistogramMediumTimes(const std::string& name, TimeDelta sample) {
82 UmaHistogramCustomTimes(name, sample, TimeDelta::FromMilliseconds(1),
83 TimeDelta::FromMinutes(3), 50);
84 }
85
86 void UmaHistogramLongTimes(const std::string& name, TimeDelta sample) {
87 UmaHistogramCustomTimes(name, sample, TimeDelta::FromMilliseconds(1),
88 TimeDelta::FromHours(1), 50);
89 }
90
91 void UmaHistogramMemoryKB(const std::string& name, int sample) {
92 UmaHistogramCustomCounts(name, sample, 1000, 500000, 50);
93 }
94
95 void UmaHistogramMemoryLargeMB(const std::string& name, int sample) {
96 UmaHistogramCustomCounts(name, sample, 1, 64000, 100);
97 }
98
99 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698