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

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. Pass 1 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(
20 const std::string& name, int sample, int value_max) {
21 HistogramBase* histogram = LinearHistogram::FactoryGet(
22 name, 1, value_max, value_max + 1,
23 HistogramBase::kUmaTargetedHistogramFlag);
24 histogram->Add(sample);
25 }
26
27 void UmaHistogramPercentage(const std::string& name, int percent) {
28 UmaHistogramExactLinear(name, percent, 100);
29 }
30
31 void UmaHistogramCustomCounts(
32 const std::string& name, int sample, int min, int max, int buckets) {
33 HistogramBase* histogram = Histogram::FactoryGet(
34 name, min, max, buckets, HistogramBase::kUmaTargetedHistogramFlag);
35 histogram->Add(sample);
36 }
37
38 void UmaHistogramCounts100(const std::string& name, int sample) {
39 UmaHistogramCustomCounts(name, sample, 1, 100, 50);
40 }
41
42 void UmaHistogramCounts1000(const std::string& name, int sample) {
43 UmaHistogramCustomCounts(name, sample, 1, 1000, 50);
44 }
45
46 void UmaHistogramCounts10000(const std::string& name, int sample) {
47 UmaHistogramCustomCounts(name, sample, 1, 10000, 50);
48 }
49
50 void UmaHistogramCounts100000(const std::string& name, int sample) {
51 UmaHistogramCustomCounts(name, sample, 1, 100000, 50);
52 }
53
54 void UmaHistogramCounts1M(const std::string& name, int sample) {
55 UmaHistogramCustomCounts(name, sample, 1, 1000000, 50);
56 }
57
58 void UmaHistogramCounts10M(const std::string& name, int sample) {
59 UmaHistogramCustomCounts(name, sample, 1, 10000000, 50);
60 }
61
62 void UmaHistogramCustomTimes(
63 const std::string& name, TimeDelta sample, TimeDelta min,
Alexei Svitkine (slow) 2016/11/12 01:43:45 Nit: 1 param per line if first one wraps. Maybe ju
nikunjb 2016/11/12 02:06:53 Done. That was convenient. :)
64 TimeDelta max, int buckets) {
65 HistogramBase* histogram = Histogram::FactoryTimeGet(
66 name, min, max, buckets, HistogramBase::kUmaTargetedHistogramFlag);
67 histogram->AddTime(sample);
68 }
69
70 void UmaHistogramTimes(const std::string& name, TimeDelta sample){
71 UmaHistogramCustomTimes(
72 name, sample, TimeDelta::FromMilliseconds(1),
73 TimeDelta::FromSeconds(10), 50);
74 }
75
76 void UmaHistogramMediumTimes(const std::string& name, TimeDelta sample) {
77 UmaHistogramCustomTimes(
78 name, sample, TimeDelta::FromMilliseconds(1),
79 TimeDelta::FromMinutes(3), 50);
80 }
81
82 void UmaHistogramLongTimes(const std::string& name, TimeDelta sample) {
83 UmaHistogramCustomTimes(
84 name, sample, TimeDelta::FromMilliseconds(1),
85 TimeDelta::FromHours(1), 50);
86 }
87
88 void UmaHistogramLongTimes100(
Alexei Svitkine (slow) 2016/11/12 01:43:45 I suggest not including this one. We tend to disco
nikunjb 2016/11/12 02:06:53 Done.
89 const std::string& name, TimeDelta sample) {
90 UmaHistogramCustomTimes(
91 name, sample, TimeDelta::FromMilliseconds(1),
92 TimeDelta::FromHours(1), 100);
93 }
94
95 void UmaHistogramMemoryKB(const std::string& name, int sample) {
96 UmaHistogramCustomCounts(name, sample, 1000, 500000, 50);
97 }
98
99 void UmaHistogramMemoryLargeMB(const std::string& name, int sample) {
100 UmaHistogramCustomCounts(name, sample, 1, 64000, 100);
101 }
102
103 } //namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698