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

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: [Remoting WebApp]Show and upload max capture/encode/render/roundtrip latency 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
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 return Math.max.apply(null, values);
109 };
110 return this.map(key, calcMax);
111 };
112
113 /**
97 * Applies a given map to the list of values for a given key. 114 * Applies a given map to the list of values for a given key.
98 * 115 *
99 * @param {string} key 116 * @param {string} key
100 * @param {function(Array<number>): number} map 117 * @param {function(Array<number>): number} map
101 * @return {number} the result of applying that map to the list of values for 118 * @return {number} the result of applying that map to the list of values for
102 * that key 119 * that key
103 */ 120 */
104 remoting.StatsAccumulator.prototype.map = function(key, map) { 121 remoting.StatsAccumulator.prototype.map = function(key, map) {
105 return map(this.getValueList(key)); 122 return map(this.getValueList(key));
106 }; 123 };
(...skipping 17 matching lines...) Expand all
124 }; 141 };
125 142
126 /** 143 /**
127 * @return {?remoting.ClientSession.PerfStats} returns null if all fields are 144 * @return {?remoting.ClientSession.PerfStats} returns null if all fields are
128 * zero. 145 * zero.
129 */ 146 */
130 remoting.StatsAccumulator.prototype.getPerfStats = function() { 147 remoting.StatsAccumulator.prototype.getPerfStats = function() {
131 var stats = new remoting.ClientSession.PerfStats(); 148 var stats = new remoting.ClientSession.PerfStats();
132 stats.videoBandwidth = this.calcMean('videoBandwidth'); 149 stats.videoBandwidth = this.calcMean('videoBandwidth');
133 stats.captureLatency = this.calcMean('captureLatency'); 150 stats.captureLatency = this.calcMean('captureLatency');
151 stats.maxCaptureLatency = this.calcMax('maxCaptureLatency');
134 stats.encodeLatency = this.calcMean('encodeLatency'); 152 stats.encodeLatency = this.calcMean('encodeLatency');
153 stats.maxEncodeLatency = this.calcMax('maxEncodeLatency');
135 stats.decodeLatency = this.calcMean('decodeLatency'); 154 stats.decodeLatency = this.calcMean('decodeLatency');
155 stats.maxDecodeLatency = this.calcMax('maxDecodeLatency');
136 stats.renderLatency = this.calcMean('renderLatency'); 156 stats.renderLatency = this.calcMean('renderLatency');
157 stats.maxRenderLatency = this.calcMax('maxRenderLatency');
137 stats.roundtripLatency = this.calcMean('roundtripLatency'); 158 stats.roundtripLatency = this.calcMean('roundtripLatency');
159 stats.maxRoundtripLatency = this.calcMax('maxRoundtripLatency');
138 160
139 for (var key in stats) { 161 for (var key in stats) {
140 if (stats[key] !== 0) { 162 if (stats[key] !== 0) {
141 return stats; 163 return stats;
142 } 164 }
143 } 165 }
144 return null; 166 return null;
145 }; 167 };
OLDNEW
« remoting/client/jni/chromoting_jni_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