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

Unified Diff: remoting/webapp/base/js/stats_accumulator.js

Issue 1811833002: Show max latency on client's status bar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Client code for uploading stats to telemetry server 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
Index: remoting/webapp/base/js/stats_accumulator.js
diff --git a/remoting/webapp/base/js/stats_accumulator.js b/remoting/webapp/base/js/stats_accumulator.js
index e0edd49653807203dd25b333d7c5f2af697fc45f..8c50a92e2b56ce699ac9cdbaf013c3ad04f7c295 100644
--- a/remoting/webapp/base/js/stats_accumulator.js
+++ b/remoting/webapp/base/js/stats_accumulator.js
@@ -94,6 +94,34 @@ remoting.StatsAccumulator.prototype.calcMean = function(key) {
};
/**
+ * Finds the max of the values for a given key.
+ *
+ * @param {string} key
+ * @return {number} the max of the values for that key
+ */
+remoting.StatsAccumulator.prototype.calcMax = function(key) {
+ /**
+ * @param {Array<number>} values
+ * @return {number}
+ */
+ var calcMax = function(values) {
+ if (values.length == 0) {
kelvinp 2016/03/21 19:14:36 can be simplified as var calcMax = function(valu
Yuwei 2016/03/21 19:29:25 Acknowledged. Interesting that Math.max doesn't ha
+ return 0.0;
+ }
+ var max = -1;
+ for (var i = 0; i < values.length; i++) {
+ if (max < values[i]) {
+ max = values[i];
+ }
+ }
+ return max;
+ };
+ return this.map(key, calcMax);
+};
+
+// Can refactor calcMean and calcMax in functional way
Sergey Ulanov 2016/03/21 19:35:06 If there is a good reason to refactor them then th
Yuwei 2016/03/21 19:59:40 Acknowledged.
+
+/**
* Applies a given map to the list of values for a given key.
*
* @param {string} key
@@ -136,6 +164,12 @@ remoting.StatsAccumulator.prototype.getPerfStats = function() {
stats.renderLatency = this.calcMean('renderLatency');
stats.roundtripLatency = this.calcMean('roundtripLatency');
+ stats.maxCaptureLatency = this.calcMax('maxCaptureLatency');
+ stats.maxEncodeLatency = this.calcMax('maxEncodeLatency');
+ stats.maxDecodeLatency = this.calcMax('maxDecodeLatency');
+ stats.maxRenderLatency = this.calcMax('maxRenderLatency');
+ stats.maxRoundtripLatency = this.calcMax('maxRoundtripLatency');
+
for (var key in stats) {
if (stats[key] !== 0) {
return stats;
« remoting/client/plugin/chromoting_instance.cc ('K') | « remoting/webapp/base/js/session_logger.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698