Chromium Code Reviews| 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 * Undefined means no rounding. | |
| 126 * @return {string} Formatted number. | 128 * @return {string} Formatted number. |
| 127 */ | 129 */ |
| 128 function formatStatNumber(value, units) { | 130 function formatStatNumber(value, units, digits) { |
| 129 if (value != undefined) { | 131 if (value != undefined) { |
| 130 return value.toFixed(2) + ' ' + units; | 132 var rounded = (digits == undefined ? digits : (value.toFixed(digits))); |
|
Sergey Ulanov
2016/03/18 19:42:06
Why would digits be undefined here?
Yuwei
2016/03/18 20:06:00
Just thinking it is possible that we may want to f
Sergey Ulanov
2016/03/18 20:17:08
In that case parameter would need to be marked as
Yuwei
2016/03/18 20:46:47
Acknowledged.
| |
| 133 return rounded + ' ' + units; | |
| 131 } else { | 134 } else { |
| 132 return "n/a"; | 135 return "n/a"; |
| 133 } | 136 } |
| 134 } | 137 } |
| 135 | 138 |
| 136 var statistics = document.getElementById('statistics'); | 139 var statistics = document.getElementById('statistics'); |
| 137 this.statsElement_.innerText = ( | 140 this.statsElement_.innerText = ( |
| 138 'Bandwidth: ' + formatStatNumber(videoBandwidth, units) + | 141 'Bandwidth: ' + formatStatNumber(videoBandwidth, units, 2) + |
| 139 ', Frame Rate: ' + formatStatNumber(stats.videoFrameRate, 'fps') + | 142 ', Frame Rate: ' + formatStatNumber(stats.videoFrameRate, 'fps', 1) + |
| 140 ', Capture: ' + formatStatNumber(stats.captureLatency, 'ms') + | 143 ', Capture: ' + formatStatNumber(stats.captureLatency, 'ms', 1) + |
| 141 ', Encode: ' + formatStatNumber(stats.encodeLatency, 'ms') + | 144 ' / ' + formatStatNumber(stats.maxCaptureLatency, 'ms', 0) + |
|
Yuwei
2016/03/18 01:46:20
average / max. Tried to save some space...
Sergey Ulanov
2016/03/18 19:42:06
This should be clear from the string. Maybe also r
Yuwei
2016/03/18 20:06:00
Do you mean the back-tick string template (`foo: $
Sergey Ulanov
2016/03/18 20:17:08
no. I was suggesting to change the UI that display
Yuwei
2016/03/18 20:46:47
I will change the UI to display stats with less sp
| |
| 142 ', Decode: ' + formatStatNumber(stats.decodeLatency, 'ms') + | 145 ', Encode: ' + formatStatNumber(stats.encodeLatency, 'ms', 1) + |
| 143 ', Render: ' + formatStatNumber(stats.renderLatency, 'ms') + | 146 ' / ' + formatStatNumber(stats.maxEncodeLatency, 'ms', 0) + |
| 144 ', Latency: ' + formatStatNumber(stats.roundtripLatency, 'ms')); | 147 ', Decode: ' + formatStatNumber(stats.decodeLatency, 'ms', 1) + |
| 148 ' / ' + formatStatNumber(stats.maxDecodeLatency, 'ms', 0) + | |
| 149 ', Render: ' + formatStatNumber(stats.renderLatency, 'ms', 1) + | |
| 150 ' / ' + formatStatNumber(stats.maxRenderLatency, 'ms', 0) + | |
| 151 ', Latency: ' + formatStatNumber(stats.roundtripLatency, 'ms', 1) + | |
| 152 ' / ' + formatStatNumber(stats.maxRoundtripLatency, 'ms', 0)); | |
| 145 }; | 153 }; |
| OLD | NEW |