Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

439 lines
18 KiB
C
Raw Normal View History

//
// Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
//
#ifndef SYSTEM_WRAPPERS_INCLUDE_METRICS_H_
#define SYSTEM_WRAPPERS_INCLUDE_METRICS_H_
#include <stddef.h>
#include <map>
#include <memory>
#include <string>
#include "rtc_base/atomic_ops.h"
#include "rtc_base/checks.h"
#if defined(RTC_DISABLE_METRICS)
#define RTC_METRICS_ENABLED 0
#else
#define RTC_METRICS_ENABLED 1
#endif
namespace webrtc {
namespace metrics_impl {
template <typename... Ts>
void NoOp(const Ts&...) {}
}
}
#if RTC_METRICS_ENABLED
#define EXPECT_METRIC_EQ(val1, val2) EXPECT_EQ(val1, val2)
#define EXPECT_METRIC_EQ_WAIT(val1, val2, timeout) \
EXPECT_EQ_WAIT(val1, val2, timeout)
#define EXPECT_METRIC_GT(val1, val2) EXPECT_GT(val1, val2)
#define EXPECT_METRIC_LE(val1, val2) EXPECT_LE(val1, val2)
#define EXPECT_METRIC_TRUE(conditon) EXPECT_TRUE(conditon)
#define EXPECT_METRIC_FALSE(conditon) EXPECT_FALSE(conditon)
#define EXPECT_METRIC_THAT(value, matcher) EXPECT_THAT(value, matcher)
#else
#define EXPECT_METRIC_EQ(val1, val2) webrtc::metrics_impl::NoOp(val1, val2)
#define EXPECT_METRIC_EQ_WAIT(val1, val2, timeout) webrtc::metrics_impl::NoOp(val1, val2, timeout)
#define EXPECT_METRIC_GT(val1, val2) webrtc::metrics_impl::NoOp(val1, val2)
#define EXPECT_METRIC_LE(val1, val2) webrtc::metrics_impl::NoOp(val1, val2)
#define EXPECT_METRIC_TRUE(condition) webrtc::metrics_impl::NoOp(condition || true)
#define EXPECT_METRIC_FALSE(condition) webrtc::metrics_impl::NoOp(condition && false)
#define EXPECT_METRIC_THAT(value, matcher) webrtc::metrics_impl::NoOp(value, testing::_)
#endif
#if RTC_METRICS_ENABLED
// Macros for allowing WebRTC clients (e.g. Chrome) to gather and aggregate
// statistics.
//
// Histogram for counters.
// RTC_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count);
//
// Histogram for enumerators.
// The boundary should be above the max enumerator sample.
// RTC_HISTOGRAM_ENUMERATION(name, sample, boundary);
//
//
// The macros use the methods HistogramFactoryGetCounts,
// HistogramFactoryGetEnumeration and HistogramAdd.
//
// By default WebRTC provides implementations of the aforementioned methods
// that can be found in system_wrappers/source/metrics.cc. If clients want to
// provide a custom version, they will have to:
//
// 1. Compile WebRTC defining the preprocessor macro
// WEBRTC_EXCLUDE_METRICS_DEFAULT (if GN is used this can be achieved
// by setting the GN arg rtc_exclude_metrics_default to true).
// 2. Provide implementations of:
// Histogram* webrtc::metrics::HistogramFactoryGetCounts(
// const std::string& name, int sample, int min, int max,
// int bucket_count);
// Histogram* webrtc::metrics::HistogramFactoryGetEnumeration(
// const std::string& name, int sample, int boundary);
// void webrtc::metrics::HistogramAdd(
// Histogram* histogram_pointer, const std::string& name, int sample);
//
// Example usage:
//
// RTC_HISTOGRAM_COUNTS("WebRTC.Video.NacksSent", nacks_sent, 1, 100000, 100);
//
// enum Types {
// kTypeX,
// kTypeY,
// kBoundary,
// };
//
// RTC_HISTOGRAM_ENUMERATION("WebRTC.Types", kTypeX, kBoundary);
//
// NOTE: It is recommended to do the Chromium review for modifications to
// histograms.xml before new metrics are committed to WebRTC.
// Macros for adding samples to a named histogram.
// Histogram for counters (exponentially spaced buckets).
#define RTC_HISTOGRAM_COUNTS_100(name, sample) \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 100, 50)
#define RTC_HISTOGRAM_COUNTS_200(name, sample) \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 200, 50)
#define RTC_HISTOGRAM_COUNTS_500(name, sample) \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 500, 50)
#define RTC_HISTOGRAM_COUNTS_1000(name, sample) \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 1000, 50)
#define RTC_HISTOGRAM_COUNTS_10000(name, sample) \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 10000, 50)
#define RTC_HISTOGRAM_COUNTS_100000(name, sample) \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 100000, 50)
#define RTC_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count) \
RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \
webrtc::metrics::HistogramFactoryGetCounts( \
name, min, max, bucket_count))
#define RTC_HISTOGRAM_COUNTS_LINEAR(name, sample, min, max, bucket_count) \
RTC_HISTOGRAM_COMMON_BLOCK(name, sample, \
webrtc::metrics::HistogramFactoryGetCountsLinear( \
name, min, max, bucket_count))
// Slow metrics: pointer to metric is acquired at each call and is not cached.
//
#define RTC_HISTOGRAM_COUNTS_SPARSE_100(name, sample) \
RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 100, 50)
#define RTC_HISTOGRAM_COUNTS_SPARSE_200(name, sample) \
RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 200, 50)
#define RTC_HISTOGRAM_COUNTS_SPARSE_500(name, sample) \
RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 500, 50)
#define RTC_HISTOGRAM_COUNTS_SPARSE_1000(name, sample) \
RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 1000, 50)
#define RTC_HISTOGRAM_COUNTS_SPARSE_10000(name, sample) \
RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 10000, 50)
#define RTC_HISTOGRAM_COUNTS_SPARSE_100000(name, sample) \
RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, 1, 100000, 50)
#define RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, min, max, bucket_count) \
RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, \
webrtc::metrics::HistogramFactoryGetCounts( \
name, min, max, bucket_count))
// Histogram for percentage (evenly spaced buckets).
#define RTC_HISTOGRAM_PERCENTAGE_SPARSE(name, sample) \
RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, 101)
// Histogram for booleans.
#define RTC_HISTOGRAM_BOOLEAN_SPARSE(name, sample) \
RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, 2)
// Histogram for enumerators (evenly spaced buckets).
// `boundary` should be above the max enumerator sample.
Reland "Reland "Replace the usage of MetricsObserverInterface by RTC_HISTOGRAM_*."" This is a reland of 1a2cc0acba6a66f89249455d8e5775849b56f755 Original change's description: > Reland "Replace the usage of MetricsObserverInterface by RTC_HISTOGRAM_*." > > This is a reland of 870bca1f418a1abf445169a638a61f9a649d557f > > Original change's description: > > Replace the usage of MetricsObserverInterface by RTC_HISTOGRAM_*. > > > > We now use RTC_HISTOGRAM_* macros in system_wrappers/include/metrics.h > > to report the metrics in pc/ and p2p/ that are currently been reported > > using MetricsObserverInterface. > > > > TBR=tommi@webrtc.org > > > > Bug: webrtc:9409 > > Change-Id: I47c9975402293c72250203fa1ec19eb1668766f6 > > Reviewed-on: https://webrtc-review.googlesource.com/83782 > > Commit-Queue: Qingsi Wang <qingsi@google.com> > > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > > Reviewed-by: Taylor (left Google) <deadbeef@webrtc.org> > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#23914} > > TBR=steveanton@webrtc.org,hta@webrtc.org,tommi@webrtc.org > > Bug: webrtc:9409 > Change-Id: I37fc95ced60dea25aa9b4f5ad44bdf7174c8bd5c > Reviewed-on: https://webrtc-review.googlesource.com/88060 > Reviewed-by: Qingsi Wang <qingsi@webrtc.org> > Commit-Queue: Qingsi Wang <qingsi@google.com> > Cr-Commit-Position: refs/heads/master@{#23919} TBR=steveanton@webrtc.org,tommi@webrtc.org Bug: webrtc:9409 Change-Id: Ib55f0b6c9bcb9d9585924a4dfac5cf643ff4d76b Reviewed-on: https://webrtc-review.googlesource.com/88343 Commit-Queue: Qingsi Wang <qingsi@google.com> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23957}
2018-07-12 12:54:53 -07:00
//
// TODO(qingsi): Refactor the default implementation given by RtcHistogram,
// which is already sparse, and remove the boundary argument from the macro.
#define RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, boundary) \
RTC_HISTOGRAM_COMMON_BLOCK_SLOW( \
name, sample, \
webrtc::metrics::SparseHistogramFactoryGetEnumeration(name, boundary))
// Histogram for percentage (evenly spaced buckets).
#define RTC_HISTOGRAM_PERCENTAGE(name, sample) \
RTC_HISTOGRAM_ENUMERATION(name, sample, 101)
// Histogram for booleans.
#define RTC_HISTOGRAM_BOOLEAN(name, sample) \
RTC_HISTOGRAM_ENUMERATION(name, sample, 2)
// Histogram for enumerators (evenly spaced buckets).
// `boundary` should be above the max enumerator sample.
#define RTC_HISTOGRAM_ENUMERATION(name, sample, boundary) \
RTC_HISTOGRAM_COMMON_BLOCK_SLOW( \
name, sample, \
webrtc::metrics::HistogramFactoryGetEnumeration(name, boundary))
// The name of the histogram should not vary.
// TODO(asapersson): Consider changing string to const char*.
#define RTC_HISTOGRAM_COMMON_BLOCK(constant_name, sample, \
factory_get_invocation) \
do { \
static webrtc::metrics::Histogram* atomic_histogram_pointer = nullptr; \
webrtc::metrics::Histogram* histogram_pointer = \
rtc::AtomicOps::AcquireLoadPtr(&atomic_histogram_pointer); \
if (!histogram_pointer) { \
histogram_pointer = factory_get_invocation; \
webrtc::metrics::Histogram* prev_pointer = \
rtc::AtomicOps::CompareAndSwapPtr( \
&atomic_histogram_pointer, \
static_cast<webrtc::metrics::Histogram*>(nullptr), \
histogram_pointer); \
RTC_DCHECK(prev_pointer == nullptr || \
prev_pointer == histogram_pointer); \
} \
if (histogram_pointer) { \
webrtc::metrics::HistogramAdd(histogram_pointer, sample); \
} \
} while (0)
// The histogram is constructed/found for each call.
// May be used for histograms with infrequent updates.`
#define RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, factory_get_invocation) \
do { \
webrtc::metrics::Histogram* histogram_pointer = factory_get_invocation; \
if (histogram_pointer) { \
webrtc::metrics::HistogramAdd(histogram_pointer, sample); \
} \
} while (0)
// Helper macros.
// Macros for calling a histogram with varying name (e.g. when using a metric
// in different modes such as real-time vs screenshare). Fast, because pointer
// is cached. `index` should be different for different names. Allowed `index`
// values are 0, 1, and 2.
#define RTC_HISTOGRAMS_COUNTS_100(index, name, sample) \
RTC_HISTOGRAMS_COMMON(index, name, sample, \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 100, 50))
#define RTC_HISTOGRAMS_COUNTS_200(index, name, sample) \
RTC_HISTOGRAMS_COMMON(index, name, sample, \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 200, 50))
#define RTC_HISTOGRAMS_COUNTS_500(index, name, sample) \
RTC_HISTOGRAMS_COMMON(index, name, sample, \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 500, 50))
#define RTC_HISTOGRAMS_COUNTS_1000(index, name, sample) \
RTC_HISTOGRAMS_COMMON(index, name, sample, \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 1000, 50))
#define RTC_HISTOGRAMS_COUNTS_10000(index, name, sample) \
RTC_HISTOGRAMS_COMMON(index, name, sample, \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 10000, 50))
#define RTC_HISTOGRAMS_COUNTS_100000(index, name, sample) \
RTC_HISTOGRAMS_COMMON(index, name, sample, \
RTC_HISTOGRAM_COUNTS(name, sample, 1, 100000, 50))
#define RTC_HISTOGRAMS_ENUMERATION(index, name, sample, boundary) \
RTC_HISTOGRAMS_COMMON(index, name, sample, \
RTC_HISTOGRAM_ENUMERATION(name, sample, boundary))
#define RTC_HISTOGRAMS_PERCENTAGE(index, name, sample) \
RTC_HISTOGRAMS_COMMON(index, name, sample, \
RTC_HISTOGRAM_PERCENTAGE(name, sample))
#define RTC_HISTOGRAMS_COMMON(index, name, sample, macro_invocation) \
do { \
switch (index) { \
case 0: \
macro_invocation; \
break; \
case 1: \
macro_invocation; \
break; \
case 2: \
macro_invocation; \
break; \
default: \
RTC_DCHECK_NOTREACHED(); \
} \
} while (0)
#else
////////////////////////////////////////////////////////////////////////////////
// This section defines no-op alternatives to the metrics macros when
// RTC_METRICS_ENABLED is defined.
#define RTC_HISTOGRAM_COUNTS_100(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_200(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_500(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_1000(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_10000(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_100000(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count) \
webrtc::metrics_impl::NoOp(name, sample, min, max, bucket_count)
#define RTC_HISTOGRAM_COUNTS_LINEAR(name, sample, min, max, bucket_count) \
webrtc::metrics_impl::NoOp(name, sample, min, max, bucket_count)
#define RTC_HISTOGRAM_COUNTS_SPARSE_100(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_200(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_500(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_1000(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_10000(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_100000(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, min, max, bucket_count) \
webrtc::metrics_impl::NoOp(name, sample, min, max, bucket_count)
#define RTC_HISTOGRAM_PERCENTAGE_SPARSE(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_BOOLEAN_SPARSE(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, boundary) \
webrtc::metrics_impl::NoOp(name, sample, boundary)
#define RTC_HISTOGRAM_PERCENTAGE(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_BOOLEAN(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_ENUMERATION(name, sample, boundary) \
webrtc::metrics_impl::NoOp(name, sample, boundary)
#define RTC_HISTOGRAM_COMMON_BLOCK(constant_name, sample, \
factory_get_invocation) \
webrtc::metrics_impl::NoOp(constant_name, sample, factory_get_invocation)
#define RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, factory_get_invocation) \
webrtc::metrics_impl::NoOp(name, sample, factory_get_invocation)
#define RTC_HISTOGRAMS_COUNTS_100(index, name, sample) webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COUNTS_200(index, name, sample) webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COUNTS_500(index, name, sample) webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COUNTS_1000(index, name, sample) \
webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COUNTS_10000(index, name, sample) \
webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COUNTS_100000(index, name, sample) \
webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_ENUMERATION(index, name, sample, boundary) \
webrtc::metrics_impl::NoOp(index, name, sample, boundary)
#define RTC_HISTOGRAMS_PERCENTAGE(index, name, sample) webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COMMON(index, name, sample, macro_invocation) \
webrtc::metrics_impl::NoOp(index, name, sample, macro_invocation)
#endif // RTC_METRICS_ENABLED
namespace webrtc {
namespace metrics {
// Time that should have elapsed for stats that are gathered once per call.
enum { kMinRunTimeInSeconds = 10 };
class Histogram;
// Functions for getting pointer to histogram (constructs or finds the named
// histogram).
// Get histogram for counters.
Revert "Reland "Make webrtc_fuzzer_main depend on webrtc_component in Chromium."" This reverts commit 8994c8bab315fa34b75a8e79b78bb99c86f69966. Reason for revert: While RTC_EXPORTS are needed, this is still not enough, I will try another approach, similar to what we do for rtc_base/logging.{cc,h}. Original change's description: > Reland "Make webrtc_fuzzer_main depend on webrtc_component in Chromium." > > This is a reland of 2148e9a931ea1a8a2ac0bfffd56e12370f8bf18c > > Original change's description: > > Make webrtc_fuzzer_main depend on webrtc_component in Chromium. > > > > This is needed in order to land [1] and restrict visibility of some > > //third_party/webrtc_overrides targets. > > > > [1] - https://chromium-review.googlesource.com/c/chromium/src/+/1930801 > > > > Bug: chromium:896154 > > Change-Id: Ie71c44ee9a0203a85d77a1199acdcb8581dfb71b > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160308 > > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#29875} > > No-Try: True > No-Tree-Checks: true > TBR: kwiberg@webrtc.org > Bug: chromium:896154 > Change-Id: I157bd4f90528a38ac16f17dd17af2f255dbd5ec9 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160401 > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29888} TBR=mbonadei@webrtc.org,kwiberg@webrtc.org Change-Id: If969618e3f0a0cd70204128f1e8a2b06cf407b6e No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:896154 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160402 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29889}
2019-11-23 15:10:32 +00:00
Histogram* HistogramFactoryGetCounts(const std::string& name,
int min,
int max,
int bucket_count);
// Get histogram for counters with linear bucket spacing.
Revert "Reland "Make webrtc_fuzzer_main depend on webrtc_component in Chromium."" This reverts commit 8994c8bab315fa34b75a8e79b78bb99c86f69966. Reason for revert: While RTC_EXPORTS are needed, this is still not enough, I will try another approach, similar to what we do for rtc_base/logging.{cc,h}. Original change's description: > Reland "Make webrtc_fuzzer_main depend on webrtc_component in Chromium." > > This is a reland of 2148e9a931ea1a8a2ac0bfffd56e12370f8bf18c > > Original change's description: > > Make webrtc_fuzzer_main depend on webrtc_component in Chromium. > > > > This is needed in order to land [1] and restrict visibility of some > > //third_party/webrtc_overrides targets. > > > > [1] - https://chromium-review.googlesource.com/c/chromium/src/+/1930801 > > > > Bug: chromium:896154 > > Change-Id: Ie71c44ee9a0203a85d77a1199acdcb8581dfb71b > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160308 > > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#29875} > > No-Try: True > No-Tree-Checks: true > TBR: kwiberg@webrtc.org > Bug: chromium:896154 > Change-Id: I157bd4f90528a38ac16f17dd17af2f255dbd5ec9 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160401 > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29888} TBR=mbonadei@webrtc.org,kwiberg@webrtc.org Change-Id: If969618e3f0a0cd70204128f1e8a2b06cf407b6e No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:896154 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160402 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29889}
2019-11-23 15:10:32 +00:00
Histogram* HistogramFactoryGetCountsLinear(const std::string& name,
int min,
int max,
int bucket_count);
// Get histogram for enumerators.
// `boundary` should be above the max enumerator sample.
Revert "Reland "Make webrtc_fuzzer_main depend on webrtc_component in Chromium."" This reverts commit 8994c8bab315fa34b75a8e79b78bb99c86f69966. Reason for revert: While RTC_EXPORTS are needed, this is still not enough, I will try another approach, similar to what we do for rtc_base/logging.{cc,h}. Original change's description: > Reland "Make webrtc_fuzzer_main depend on webrtc_component in Chromium." > > This is a reland of 2148e9a931ea1a8a2ac0bfffd56e12370f8bf18c > > Original change's description: > > Make webrtc_fuzzer_main depend on webrtc_component in Chromium. > > > > This is needed in order to land [1] and restrict visibility of some > > //third_party/webrtc_overrides targets. > > > > [1] - https://chromium-review.googlesource.com/c/chromium/src/+/1930801 > > > > Bug: chromium:896154 > > Change-Id: Ie71c44ee9a0203a85d77a1199acdcb8581dfb71b > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160308 > > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#29875} > > No-Try: True > No-Tree-Checks: true > TBR: kwiberg@webrtc.org > Bug: chromium:896154 > Change-Id: I157bd4f90528a38ac16f17dd17af2f255dbd5ec9 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160401 > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29888} TBR=mbonadei@webrtc.org,kwiberg@webrtc.org Change-Id: If969618e3f0a0cd70204128f1e8a2b06cf407b6e No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:896154 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160402 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29889}
2019-11-23 15:10:32 +00:00
Histogram* HistogramFactoryGetEnumeration(const std::string& name,
int boundary);
// Get sparse histogram for enumerators.
// `boundary` should be above the max enumerator sample.
Revert "Reland "Make webrtc_fuzzer_main depend on webrtc_component in Chromium."" This reverts commit 8994c8bab315fa34b75a8e79b78bb99c86f69966. Reason for revert: While RTC_EXPORTS are needed, this is still not enough, I will try another approach, similar to what we do for rtc_base/logging.{cc,h}. Original change's description: > Reland "Make webrtc_fuzzer_main depend on webrtc_component in Chromium." > > This is a reland of 2148e9a931ea1a8a2ac0bfffd56e12370f8bf18c > > Original change's description: > > Make webrtc_fuzzer_main depend on webrtc_component in Chromium. > > > > This is needed in order to land [1] and restrict visibility of some > > //third_party/webrtc_overrides targets. > > > > [1] - https://chromium-review.googlesource.com/c/chromium/src/+/1930801 > > > > Bug: chromium:896154 > > Change-Id: Ie71c44ee9a0203a85d77a1199acdcb8581dfb71b > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160308 > > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#29875} > > No-Try: True > No-Tree-Checks: true > TBR: kwiberg@webrtc.org > Bug: chromium:896154 > Change-Id: I157bd4f90528a38ac16f17dd17af2f255dbd5ec9 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160401 > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29888} TBR=mbonadei@webrtc.org,kwiberg@webrtc.org Change-Id: If969618e3f0a0cd70204128f1e8a2b06cf407b6e No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:896154 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160402 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29889}
2019-11-23 15:10:32 +00:00
Histogram* SparseHistogramFactoryGetEnumeration(const std::string& name,
int boundary);
// Function for adding a `sample` to a histogram.
Revert "Reland "Make webrtc_fuzzer_main depend on webrtc_component in Chromium."" This reverts commit 8994c8bab315fa34b75a8e79b78bb99c86f69966. Reason for revert: While RTC_EXPORTS are needed, this is still not enough, I will try another approach, similar to what we do for rtc_base/logging.{cc,h}. Original change's description: > Reland "Make webrtc_fuzzer_main depend on webrtc_component in Chromium." > > This is a reland of 2148e9a931ea1a8a2ac0bfffd56e12370f8bf18c > > Original change's description: > > Make webrtc_fuzzer_main depend on webrtc_component in Chromium. > > > > This is needed in order to land [1] and restrict visibility of some > > //third_party/webrtc_overrides targets. > > > > [1] - https://chromium-review.googlesource.com/c/chromium/src/+/1930801 > > > > Bug: chromium:896154 > > Change-Id: Ie71c44ee9a0203a85d77a1199acdcb8581dfb71b > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160308 > > Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> > > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#29875} > > No-Try: True > No-Tree-Checks: true > TBR: kwiberg@webrtc.org > Bug: chromium:896154 > Change-Id: I157bd4f90528a38ac16f17dd17af2f255dbd5ec9 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160401 > Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29888} TBR=mbonadei@webrtc.org,kwiberg@webrtc.org Change-Id: If969618e3f0a0cd70204128f1e8a2b06cf407b6e No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:896154 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160402 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29889}
2019-11-23 15:10:32 +00:00
void HistogramAdd(Histogram* histogram_pointer, int sample);
struct SampleInfo {
SampleInfo(const std::string& name, int min, int max, size_t bucket_count);
~SampleInfo();
const std::string name;
const int min;
const int max;
const size_t bucket_count;
std::map<int, int> samples; // <value, # of events>
};
// Enables collection of samples.
// This method should be called before any other call into webrtc.
void Enable();
// Gets histograms and clears all samples.
void GetAndReset(
std::map<std::string, std::unique_ptr<SampleInfo>>* histograms);
// Functions below are mainly for testing.
// Clears all samples.
void Reset();
// Returns the number of times the `sample` has been added to the histogram.
int NumEvents(const std::string& name, int sample);
// Returns the total number of added samples to the histogram.
int NumSamples(const std::string& name);
// Returns the minimum sample value (or -1 if the histogram has no samples).
int MinSample(const std::string& name);
// Returns a map with keys the samples with at least one event and values the
// number of events for that sample.
std::map<int, int> Samples(const std::string& name);
} // namespace metrics
} // namespace webrtc
#endif // SYSTEM_WRAPPERS_INCLUDE_METRICS_H_