blob: 94ba3cda321b7e1abea52d04d29958efeae4e52e [file] [log] [blame]
asapersson01d70a32016-05-20 06:29:46 -07001/*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_METRICS_DEFAULT_H_
12#define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_METRICS_DEFAULT_H_
13
14#include <map>
15#include <memory>
16#include <string>
17
18namespace webrtc {
19namespace metrics {
20
sakal2a5f3712016-09-09 00:11:48 -070021// This class does not actually exist. It is casted to an implementation defined
22// pointer inside the functions.
23class Histogram;
24
asapersson01d70a32016-05-20 06:29:46 -070025struct SampleInfo {
26 SampleInfo(const std::string& name, int min, int max, size_t bucket_count);
27 ~SampleInfo();
28
29 const std::string name;
30 const int min;
31 const int max;
32 const size_t bucket_count;
33 std::map<int, int> samples; // <value, # of events>
34};
35
36// Enables collection of samples.
37// This method should be called before any other call into webrtc.
38void Enable();
39
40// Gets histograms and clears all samples.
41void GetAndReset(
42 std::map<std::string, std::unique_ptr<SampleInfo>>* histograms);
43
44// Functions below are mainly for testing.
45
46// Clears all samples.
47void Reset();
48
49// Returns the number of times the |sample| has been added to the histogram.
50int NumEvents(const std::string& name, int sample);
51
52// Returns the total number of added samples to the histogram.
53int NumSamples(const std::string& name);
54
55// Returns the minimum sample value (or -1 if the histogram has no samples).
56int MinSample(const std::string& name);
57
sakal2a5f3712016-09-09 00:11:48 -070058// Function for adding a |sample| to a histogram without checkking the name.
59void HistogramAdd(Histogram* histogram_pointer, int sample);
60
asapersson01d70a32016-05-20 06:29:46 -070061} // namespace metrics
62} // namespace webrtc
63
64#endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_METRICS_DEFAULT_H_