| Index: base/metrics/histogram_functions.cc
|
| diff --git a/base/metrics/histogram_functions.cc b/base/metrics/histogram_functions.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..67dd2f8c6d1610a48a5d8d12888d6d9197eb6322
|
| --- /dev/null
|
| +++ b/base/metrics/histogram_functions.cc
|
| @@ -0,0 +1,99 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/metrics/histogram_functions.h"
|
| +
|
| +#include "base/metrics/histogram.h"
|
| +#include "base/metrics/histogram_base.h"
|
| +#include "base/time/time.h"
|
| +
|
| +namespace base {
|
| +
|
| +void UmaHistogramBoolean(const std::string& name, bool sample) {
|
| + HistogramBase* histogram = BooleanHistogram::FactoryGet(
|
| + name, base::HistogramBase::kUmaTargetedHistogramFlag);
|
| + histogram->Add(sample);
|
| +}
|
| +
|
| +void UmaHistogramExactLinear(const std::string& name,
|
| + int sample,
|
| + int value_max) {
|
| + HistogramBase* histogram =
|
| + LinearHistogram::FactoryGet(name, 1, value_max, value_max + 1,
|
| + HistogramBase::kUmaTargetedHistogramFlag);
|
| + histogram->Add(sample);
|
| +}
|
| +
|
| +void UmaHistogramPercentage(const std::string& name, int percent) {
|
| + UmaHistogramExactLinear(name, percent, 100);
|
| +}
|
| +
|
| +void UmaHistogramCustomCounts(const std::string& name,
|
| + int sample,
|
| + int min,
|
| + int max,
|
| + int buckets) {
|
| + HistogramBase* histogram = Histogram::FactoryGet(
|
| + name, min, max, buckets, HistogramBase::kUmaTargetedHistogramFlag);
|
| + histogram->Add(sample);
|
| +}
|
| +
|
| +void UmaHistogramCounts100(const std::string& name, int sample) {
|
| + UmaHistogramCustomCounts(name, sample, 1, 100, 50);
|
| +}
|
| +
|
| +void UmaHistogramCounts1000(const std::string& name, int sample) {
|
| + UmaHistogramCustomCounts(name, sample, 1, 1000, 50);
|
| +}
|
| +
|
| +void UmaHistogramCounts10000(const std::string& name, int sample) {
|
| + UmaHistogramCustomCounts(name, sample, 1, 10000, 50);
|
| +}
|
| +
|
| +void UmaHistogramCounts100000(const std::string& name, int sample) {
|
| + UmaHistogramCustomCounts(name, sample, 1, 100000, 50);
|
| +}
|
| +
|
| +void UmaHistogramCounts1M(const std::string& name, int sample) {
|
| + UmaHistogramCustomCounts(name, sample, 1, 1000000, 50);
|
| +}
|
| +
|
| +void UmaHistogramCounts10M(const std::string& name, int sample) {
|
| + UmaHistogramCustomCounts(name, sample, 1, 10000000, 50);
|
| +}
|
| +
|
| +void UmaHistogramCustomTimes(const std::string& name,
|
| + TimeDelta sample,
|
| + TimeDelta min,
|
| + TimeDelta max,
|
| + int buckets) {
|
| + HistogramBase* histogram = Histogram::FactoryTimeGet(
|
| + name, min, max, buckets, HistogramBase::kUmaTargetedHistogramFlag);
|
| + histogram->AddTime(sample);
|
| +}
|
| +
|
| +void UmaHistogramTimes(const std::string& name, TimeDelta sample) {
|
| + UmaHistogramCustomTimes(name, sample, TimeDelta::FromMilliseconds(1),
|
| + TimeDelta::FromSeconds(10), 50);
|
| +}
|
| +
|
| +void UmaHistogramMediumTimes(const std::string& name, TimeDelta sample) {
|
| + UmaHistogramCustomTimes(name, sample, TimeDelta::FromMilliseconds(1),
|
| + TimeDelta::FromMinutes(3), 50);
|
| +}
|
| +
|
| +void UmaHistogramLongTimes(const std::string& name, TimeDelta sample) {
|
| + UmaHistogramCustomTimes(name, sample, TimeDelta::FromMilliseconds(1),
|
| + TimeDelta::FromHours(1), 50);
|
| +}
|
| +
|
| +void UmaHistogramMemoryKB(const std::string& name, int sample) {
|
| + UmaHistogramCustomCounts(name, sample, 1000, 500000, 50);
|
| +}
|
| +
|
| +void UmaHistogramMemoryLargeMB(const std::string& name, int sample) {
|
| + UmaHistogramCustomCounts(name, sample, 1, 64000, 100);
|
| +}
|
| +
|
| +} // namespace base
|
|
|