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

Unified Diff: remoting/base/running_samples.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/base/running_samples.h ('k') | remoting/base/running_samples_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/running_samples.cc
diff --git a/remoting/base/running_average.cc b/remoting/base/running_samples.cc
similarity index 51%
rename from remoting/base/running_average.cc
rename to remoting/base/running_samples.cc
index 5e24c0de3a95672c1e4f8d4c5b67cf5b11db81ba..d76a1a688d8458e6c3d1cd2c644c4e5ca6b4dd9f 100644
--- a/remoting/base/running_average.cc
+++ b/remoting/base/running_samples.cc
@@ -1,22 +1,23 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright 2016 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.
-#include "remoting/base/running_average.h"
+#include "remoting/base/running_samples.h"
+
+#include <algorithm>
#include "base/logging.h"
namespace remoting {
-RunningAverage::RunningAverage(int window_size)
- : window_size_(window_size),
- sum_(0) {
+RunningSamples::RunningSamples(int window_size)
+ : window_size_(window_size) {
DCHECK_GT(window_size, 0);
}
-RunningAverage::~RunningAverage() {}
+RunningSamples::~RunningSamples() {}
-void RunningAverage::Record(int64_t value) {
+void RunningSamples::Record(int64_t value) {
DCHECK(thread_checker_.CalledOnValidThread());
data_points_.push_back(value);
@@ -28,7 +29,7 @@ void RunningAverage::Record(int64_t value) {
}
}
-double RunningAverage::Average() {
+double RunningSamples::Average() const {
DCHECK(thread_checker_.CalledOnValidThread());
if (data_points_.empty())
@@ -36,4 +37,13 @@ double RunningAverage::Average() {
return static_cast<double>(sum_) / data_points_.size();
}
+int64_t RunningSamples::Max() const {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ if (data_points_.empty())
+ return 0;
+
+ return *std::max_element(data_points_.begin(), data_points_.end());
+}
+
} // namespace remoting
« no previous file with comments | « remoting/base/running_samples.h ('k') | remoting/base/running_samples_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698