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

Side by Side 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: 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/webapp/base/js/session_logger.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * The webapp reads the plugin's connection statistics frequently (once per 7 * The webapp reads the plugin's connection statistics frequently (once per
8 * second). It logs statistics to the server less frequently, to keep 8 * second). It logs statistics to the server less frequently, to keep
9 * bandwidth and storage costs down. This class bridges that gap, by 9 * bandwidth and storage costs down. This class bridges that gap, by
10 * accumulating high-frequency numeric data, and providing statistics 10 * accumulating high-frequency numeric data, and providing statistics
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 var sum = 0; 87 var sum = 0;
88 for (var i = 0; i < values.length; i++) { 88 for (var i = 0; i < values.length; i++) {
89 sum += values[i]; 89 sum += values[i];
90 } 90 }
91 return sum / values.length; 91 return sum / values.length;
92 }; 92 };
93 return this.map(key, calcMean); 93 return this.map(key, calcMean);
94 }; 94 };
95 95
96 /** 96 /**
97 * Finds the max of the values for a given key.
98 *
99 * @param {string} key
100 * @return {number} the max of the values for that key
101 */
102 remoting.StatsAccumulator.prototype.calcMax = function(key) {
103 /**
104 * @param {Array<number>} values
105 * @return {number}
106 */
107 var calcMax = function(values) {
108 if (!values || !values.length) {
109 return 0;
110 }
111 return Math.max.apply(null, values);
112 };
113 return this.map(key, calcMax);
114 };
115
116 /**
97 * Applies a given map to the list of values for a given key. 117 * Applies a given map to the list of values for a given key.
98 * 118 *
99 * @param {string} key 119 * @param {string} key
100 * @param {function(Array<number>): number} map 120 * @param {function(Array<number>): number} map
101 * @return {number} the result of applying that map to the list of values for 121 * @return {number} the result of applying that map to the list of values for
102 * that key 122 * that key
103 */ 123 */
104 remoting.StatsAccumulator.prototype.map = function(key, map) { 124 remoting.StatsAccumulator.prototype.map = function(key, map) {
105 return map(this.getValueList(key)); 125 return map(this.getValueList(key));
106 }; 126 };
(...skipping 17 matching lines...) Expand all
124 }; 144 };
125 145
126 /** 146 /**
127 * @return {?remoting.ClientSession.PerfStats} returns null if all fields are 147 * @return {?remoting.ClientSession.PerfStats} returns null if all fields are
128 * zero. 148 * zero.
129 */ 149 */
130 remoting.StatsAccumulator.prototype.getPerfStats = function() { 150 remoting.StatsAccumulator.prototype.getPerfStats = function() {
131 var stats = new remoting.ClientSession.PerfStats(); 151 var stats = new remoting.ClientSession.PerfStats();
132 stats.videoBandwidth = this.calcMean('videoBandwidth'); 152 stats.videoBandwidth = this.calcMean('videoBandwidth');
133 stats.captureLatency = this.calcMean('captureLatency'); 153 stats.captureLatency = this.calcMean('captureLatency');
154 stats.maxCaptureLatency = this.calcMax('maxCaptureLatency');
134 stats.encodeLatency = this.calcMean('encodeLatency'); 155 stats.encodeLatency = this.calcMean('encodeLatency');
156 stats.maxEncodeLatency = this.calcMax('maxEncodeLatency');
135 stats.decodeLatency = this.calcMean('decodeLatency'); 157 stats.decodeLatency = this.calcMean('decodeLatency');
158 stats.maxDecodeLatency = this.calcMax('maxDecodeLatency');
136 stats.renderLatency = this.calcMean('renderLatency'); 159 stats.renderLatency = this.calcMean('renderLatency');
160 stats.maxRenderLatency = this.calcMax('maxRenderLatency');
137 stats.roundtripLatency = this.calcMean('roundtripLatency'); 161 stats.roundtripLatency = this.calcMean('roundtripLatency');
162 stats.maxRoundtripLatency = this.calcMax('maxRoundtripLatency');
138 163
139 for (var key in stats) { 164 for (var key in stats) {
140 if (stats[key] !== 0) { 165 if (stats[key] !== 0) {
141 return stats; 166 return stats;
142 } 167 }
143 } 168 }
144 return null; 169 return null;
145 }; 170 };
OLDNEW
« no previous file with comments | « 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