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

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

Issue 1811833002: Show max latency on client's status bar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: JS compiler fix and lld fix 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/BUILD.gn ('k') | remoting/base/running_average.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 (c) 2011 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_AVERAGE_H_
6 #define REMOTING_BASE_RUNNING_AVERAGE_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 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 RunningAverage {
22 public:
23 // Constructs a helper to average over the |window_size| most recent samples.
24 explicit RunningAverage(int window_size);
25 virtual ~RunningAverage();
26
27 // Records a point sample.
28 void Record(int64_t value);
29
30 // Returns the average over up to |window_size| of the most recent samples.
31 double Average();
32
33 private:
34 // Stores the desired window size, as size_t to avoid casting when comparing
35 // with the size of |data_points_|.
36 const size_t window_size_;
37
38 // Stores the |window_size| most recently recorded samples.
39 std::deque<int64_t> data_points_;
40
41 // Holds the sum of the samples in |data_points_|.
42 int64_t sum_;
43
44 base::ThreadChecker thread_checker_;
45
46 DISALLOW_COPY_AND_ASSIGN(RunningAverage);
47 };
48
49 } // namespace remoting
50
51 #endif // REMOTING_BASE_RUNNING_AVERAGE_H_
OLDNEW
« no previous file with comments | « remoting/base/BUILD.gn ('k') | remoting/base/running_average.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698