Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
Alexei Svitkine (slow)
2016/11/12 00:51:14
2016 and remove the (c)
nikunjb
2016/11/12 01:35:15
Done.
| |
| 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 // For adding boolean sample to histogram. | |
| 14 // Sample usage: | |
| 15 // base::UmaHistogramBoolean("My.Boolean", true) | |
|
Alexei Svitkine (slow)
2016/11/12 00:51:14
Remove the function comments from the .cc - they s
nikunjb
2016/11/12 01:35:15
Done.
| |
| 16 void UmaHistogramBoolean(const std::string& name, bool sample) { | |
| 17 HistogramBase* histogram = BooleanHistogram::FactoryGet( | |
| 18 name, base::HistogramBase::kUmaTargetedHistogramFlag); | |
| 19 histogram->Add(sample); | |
| 20 } | |
| 21 | |
| 22 // For histograms with linear buckets. | |
| 23 // Used for capturing integer data with a linear bucketing scheme. This can be | |
| 24 // used when you want the exact value of some small numeric count, with a max of | |
| 25 // 100 or less. If you need to capture a range of greater than 100, we recommend | |
| 26 // the use of the COUNT histograms below. | |
| 27 // Sample usage: | |
| 28 // base::UmaHistogramExactLinear("Histogram.Linear", some_value, 10); | |
| 29 void UmaHistogramExactLinear( | |
| 30 const std::string& name, int sample, int value_max) { | |
| 31 HistogramBase* histogram = LinearHistogram::FactoryGet( | |
| 32 name, 1, value_max, value_max + 1, | |
| 33 HistogramBase::kUmaTargetedHistogramFlag); | |
| 34 histogram->Add(sample); | |
| 35 } | |
| 36 | |
| 37 // For adding histogram with percent. | |
| 38 // Percents are integer between 1 and 100. | |
| 39 // Sample usage: | |
| 40 // base::UmaHistogramPercentage("My.Percent", 69) | |
| 41 void UmaHistogramPercentage(const std::string& name, int percent) { | |
| 42 UmaHistogramExactLinear(name, percent, 100); | |
| 43 } | |
| 44 | |
| 45 // For adding counts histogram. | |
| 46 // Sample usage: | |
| 47 // base::UmaHistogramCounts("My.Counts", some_value, 1, 600, 30) | |
| 48 void UmaHistogramCustomCounts( | |
| 49 const std::string& name, int sample, int min, int max, int buckets) { | |
| 50 HistogramBase* histogram = Histogram::FactoryGet( | |
| 51 name, min, max, buckets, HistogramBase::kUmaTargetedHistogramFlag); | |
| 52 histogram->Add(sample); | |
| 53 } | |
| 54 | |
| 55 // Counts specialization for maximum counts 100, 1000, 10k, 100k, 1M and 10M. | |
| 56 void UmaHistogramCounts100(const std::string& name, int sample) { | |
| 57 UmaHistogramCustomCounts(name, sample, 1, 100, 50); | |
| 58 } | |
| 59 | |
| 60 void UmaHistogramCounts1000(const std::string& name, int sample) { | |
| 61 UmaHistogramCustomCounts(name, sample, 1, 1000, 50); | |
| 62 } | |
| 63 | |
| 64 void UmaHistogramCounts10000(const std::string& name, int sample) { | |
| 65 UmaHistogramCustomCounts(name, sample, 1, 10000, 50); | |
| 66 } | |
| 67 | |
| 68 void UmaHistogramCounts100000(const std::string& name, int sample) { | |
| 69 UmaHistogramCustomCounts(name, sample, 1, 100000, 50); | |
| 70 } | |
| 71 | |
| 72 void UmaHistogramCounts1M(const std::string& name, int sample) { | |
| 73 UmaHistogramCustomCounts(name, sample, 1, 1000000, 50); | |
| 74 } | |
| 75 | |
| 76 void UmaHistogramCounts10M(const std::string& name, int sample) { | |
| 77 UmaHistogramCustomCounts(name, sample, 1, 10000000, 50); | |
| 78 } | |
| 79 | |
| 80 // For histograms storing times. | |
| 81 void UmaHistogramCustomTimes( | |
| 82 const std::string& name, const TimeDelta& sample, const TimeDelta& min, | |
| 83 const TimeDelta& max, int buckets) { | |
| 84 HistogramBase* histogram = Histogram::FactoryTimeGet( | |
| 85 name, min, max, buckets, HistogramBase::kUmaTargetedHistogramFlag); | |
| 86 histogram->AddTime(sample); | |
| 87 } | |
| 88 | |
| 89 void UmaHistogramTimes(const std::string& name, const TimeDelta& sample){ | |
| 90 UmaHistogramCustomTimes( | |
| 91 name, sample, TimeDelta::FromMilliseconds(1), | |
| 92 TimeDelta::FromSeconds(10), 50); | |
| 93 } | |
| 94 | |
| 95 void UmaHistogramMediumTimes(const std::string& name, const TimeDelta& sample) { | |
| 96 UmaHistogramCustomTimes( | |
| 97 name, sample, TimeDelta::FromMilliseconds(1), | |
| 98 TimeDelta::FromMinutes(3), 50); | |
| 99 } | |
| 100 | |
| 101 void UmaHistogramLongTimes(const std::string& name, const TimeDelta& sample) { | |
| 102 UmaHistogramCustomTimes( | |
| 103 name, sample, TimeDelta::FromMilliseconds(1), | |
| 104 TimeDelta::FromHours(1), 50); | |
| 105 } | |
| 106 | |
| 107 void UmaHistogramLongTimes100( | |
| 108 const std::string& name, const TimeDelta& sample) { | |
| 109 UmaHistogramCustomTimes( | |
| 110 name, sample, TimeDelta::FromMilliseconds(1), | |
| 111 TimeDelta::FromHours(1), 100); | |
| 112 } | |
| 113 | |
| 114 // For recording memory related histograms. | |
| 115 void UmaHistogramMemoryKB(const std::string& name, int sample) { | |
| 116 UmaHistogramCustomCounts(name, sample, 1000, 500000, 50); | |
| 117 } | |
| 118 | |
| 119 void UmaHistogramMemoryLargeMB(const std::string& name, int sample) { | |
| 120 UmaHistogramCustomCounts(name, sample, 1, 64000, 100); | |
| 121 } | |
| 122 | |
| 123 } //namespace base | |
| OLD | NEW |