Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: remoting/base/running_samples.h

Issue 1817093005: Revert of Show max latency on client's status bar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/base/running_average_unittest.cc ('k') | remoting/base/running_samples.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 REMOTING_BASE_RUNNING_SAMPLES_H_
6 #define REMOTING_BASE_RUNNING_SAMPLES_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <deque>
12
13 #include "base/macros.h"
14 #include "base/threading/thread_checker.h"
15
16 namespace remoting {
17
18 // Calculates the maximum or average of the most recent N recorded samples.
19 // This is typically used to smooth out random variation in point samples
20 // over bandwidth, frame rate, etc.
21 class RunningSamples {
22 public:
23 // Constructs a running sample helper that stores |window_size| most
24 // recent samples.
25 explicit RunningSamples(int window_size);
26 virtual ~RunningSamples();
27
28 // Records a point sample.
29 void Record(int64_t value);
30
31 // Returns the average over up to |window_size| of the most recent samples.
32 // 0 if no sample available
33 double Average() const;
34
35 // Returns the max over up to |window_size| of the most recent samples.
36 // 0 if no sample available
37 int64_t Max() const;
38
39 private:
40 // Stores the desired window size, as size_t to avoid casting when comparing
41 // with the size of |data_points_|.
42 const size_t window_size_;
43
44 // Stores the |window_size| most recently recorded samples.
45 std::deque<int64_t> data_points_;
46
47 // Holds the sum of the samples in |data_points_|.
48 int64_t sum_ = 0;
49
50 base::ThreadChecker thread_checker_;
51
52 DISALLOW_COPY_AND_ASSIGN(RunningSamples);
53 };
54
55 } // namespace remoting
56
57 #endif // REMOTING_BASE_RUNNING_SAMPLES_H_
OLDNEW
« no previous file with comments | « remoting/base/running_average_unittest.cc ('k') | remoting/base/running_samples.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698