| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * Module to support debug overlay window with connection stats. | 7 * Module to support debug overlay window with connection stats. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 videoBandwidth = videoBandwidth / 1048576; | 116 videoBandwidth = videoBandwidth / 1048576; |
| 117 } else { | 117 } else { |
| 118 units = 'GiBps'; | 118 units = 'GiBps'; |
| 119 videoBandwidth = videoBandwidth / 1073741824; | 119 videoBandwidth = videoBandwidth / 1073741824; |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 /** | 123 /** |
| 124 * @param {number} value | 124 * @param {number} value |
| 125 * @param {string} units | 125 * @param {string} units |
| 126 * @param {number} number of digits after decimal. | |
| 127 * @return {string} Formatted number. | 126 * @return {string} Formatted number. |
| 128 */ | 127 */ |
| 129 function formatStatNumber(value, units, digits) { | 128 function formatStatNumber(value, units) { |
| 130 if (value != undefined) { | 129 if (value != undefined) { |
| 131 return value.toFixed(digits) + ' ' + units; | 130 return value.toFixed(2) + ' ' + units; |
| 132 } else { | 131 } else { |
| 133 return "n/a"; | 132 return "n/a"; |
| 134 } | 133 } |
| 135 } | 134 } |
| 136 | 135 |
| 137 /** | |
| 138 * @param {string} type | |
| 139 * @param {number} avg | |
| 140 * @param {number} max | |
| 141 * @return {string} "type: avg, max; " e.g. "RTT: 8.0, 13; " | |
| 142 */ | |
| 143 function formatStat(type, avg, max) { | |
| 144 return type + ': ' + avg.toFixed(1) + ', ' + max + '; '; | |
| 145 } | |
| 146 | |
| 147 var statistics = document.getElementById('statistics'); | 136 var statistics = document.getElementById('statistics'); |
| 148 this.statsElement_.innerText = ( | 137 this.statsElement_.innerText = ( |
| 149 '(avg, max in ms) ' + | 138 'Bandwidth: ' + formatStatNumber(videoBandwidth, units) + |
| 150 formatStat('Capture', stats.captureLatency, stats.maxCaptureLatency) + | 139 ', Frame Rate: ' + formatStatNumber(stats.videoFrameRate, 'fps') + |
| 151 formatStat('Encode', stats.encodeLatency, stats.maxEncodeLatency) + | 140 ', Capture: ' + formatStatNumber(stats.captureLatency, 'ms') + |
| 152 formatStat('Decode', stats.decodeLatency, stats.maxDecodeLatency) + | 141 ', Encode: ' + formatStatNumber(stats.encodeLatency, 'ms') + |
| 153 formatStat('Render', stats.renderLatency, stats.maxRenderLatency) + | 142 ', Decode: ' + formatStatNumber(stats.decodeLatency, 'ms') + |
| 154 formatStat('RTT', stats.roundtripLatency, stats.maxRoundtripLatency) + | 143 ', Render: ' + formatStatNumber(stats.renderLatency, 'ms') + |
| 155 'Bandwidth: ' + formatStatNumber(videoBandwidth, units, 2) + '; ' + | 144 ', Latency: ' + formatStatNumber(stats.roundtripLatency, 'ms')); |
| 156 'Frame Rate: ' + formatStatNumber(stats.videoFrameRate, 'fps', 1) | |
| 157 ); | |
| 158 }; | 145 }; |
| OLD | NEW |