OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_BASE_ANDROID_TEST_STATISTICS_H_ | |
6 #define MEDIA_BASE_ANDROID_TEST_STATISTICS_H_ | |
7 | |
8 namespace media { | |
9 | |
10 // Class that computes statistics: number of calls, minimum and maximum values. | |
11 // It is used for in tests PTS statistics to verify that playback did actually | |
12 // happen. | |
13 | |
14 template <typename T> | |
15 class Minimax { | |
16 public: | |
17 Minimax() : num_values_(0) {} | |
18 ~Minimax() {} | |
19 | |
20 void AddValue(const T& value) { | |
21 if (num_values_ == 0) | |
22 min_ = max_ = value; | |
23 else if (value < min_) | |
24 min_ = value; | |
25 else if (max_ < value) | |
26 max_ = value; | |
27 | |
28 ++num_values_; | |
29 } | |
30 | |
31 void Clear() { | |
32 min_ = T(); | |
33 max_ = T(); | |
34 num_values_ = 0; | |
35 } | |
36 | |
37 const T& min() const { return min_; } | |
38 const T& max() const { return max_; } | |
39 int num_values() const { return num_values_; } | |
40 | |
41 private: | |
42 T min_; | |
43 T max_; | |
44 int num_values_; | |
45 }; | |
46 | |
47 } // namespace media | |
48 | |
49 #endif // MEDIA_BASE_ANDROID_TEST_STATISTICS_H_ | |
OLD | NEW |