blob: 9c889b49943c42984abb1b74a1771d74c3576ba7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright 2015 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.
#ifndef MEDIA_BASE_ANDROID_TEST_STATISTICS_H_
#define MEDIA_BASE_ANDROID_TEST_STATISTICS_H_
namespace media {
// Class that computes statistics: number of calls, minimum and maximum values.
// It is used for in tests PTS statistics to verify that playback did actually
// happen.
template <typename T>
class Minimax {
public:
Minimax() : num_values_(0) {}
~Minimax() {}
void AddValue(const T& value) {
if (num_values_ == 0)
min_ = max_ = value;
else if (value < min_)
min_ = value;
else if (max_ < value)
max_ = value;
++num_values_;
}
void Clear() {
min_ = T();
max_ = T();
num_values_ = 0;
}
const T& min() const { return min_; }
const T& max() const { return max_; }
int num_values() const { return num_values_; }
private:
T min_;
T max_;
int num_values_;
};
} // namespace media
#endif // MEDIA_BASE_ANDROID_TEST_STATISTICS_H_
|