blob: 39af1c6a37446b5994490b788effb922a9dcd9fe [file] [log] [blame]
Sebastian Janssonefa3f762019-12-02 07:19:55 +01001/*
2 * Copyright (c) 2019 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#ifndef RTC_BASE_NUMERICS_SAMPLE_STATS_H_
11#define RTC_BASE_NUMERICS_SAMPLE_STATS_H_
12
Artem Titov9d777622020-09-18 18:23:08 +020013#include "api/numerics/samples_stats_counter.h"
Sebastian Janssonefa3f762019-12-02 07:19:55 +010014#include "api/units/data_rate.h"
15#include "api/units/time_delta.h"
16#include "api/units/timestamp.h"
Sebastian Janssonefa3f762019-12-02 07:19:55 +010017
18namespace webrtc {
19template <typename T>
20class SampleStats;
21
22// TODO(srte): Merge this implementation with SamplesStatsCounter.
23template <>
24class SampleStats<double> : public SamplesStatsCounter {
25 public:
26 double Max();
27 double Mean();
28 double Median();
29 double Quantile(double quantile);
30 double Min();
31 double Variance();
32 double StandardDeviation();
33 int Count();
34};
35
36template <>
37class SampleStats<TimeDelta> {
38 public:
39 void AddSample(TimeDelta delta);
40 void AddSampleMs(double delta_ms);
41 void AddSamples(const SampleStats<TimeDelta>& other);
42 bool IsEmpty();
43 TimeDelta Max();
44 TimeDelta Mean();
45 TimeDelta Median();
46 TimeDelta Quantile(double quantile);
47 TimeDelta Min();
48 TimeDelta Variance();
49 TimeDelta StandardDeviation();
50 int Count();
51
52 private:
53 SampleStats<double> stats_;
54};
55
56template <>
57class SampleStats<DataRate> {
58 public:
59 void AddSample(DataRate rate);
60 void AddSampleBps(double rate_bps);
61 void AddSamples(const SampleStats<DataRate>& other);
62 bool IsEmpty();
63 DataRate Max();
64 DataRate Mean();
65 DataRate Median();
66 DataRate Quantile(double quantile);
67 DataRate Min();
68 DataRate Variance();
69 DataRate StandardDeviation();
70 int Count();
71
72 private:
73 SampleStats<double> stats_;
74};
75} // namespace webrtc
76
77#endif // RTC_BASE_NUMERICS_SAMPLE_STATS_H_