Better format for timing log
Calculating the duration when reporting timings often suffered floating point round-offs that harmed the legibility of the log. For example, rendering a diff might have logged the following. Diff Syntax Render: 71.60000000000036 With this change, the value is rounded and units are added, so the same log message appears like the following. Diff Syntax Render: 72ms Change-Id: Ib52349ea796734189efe2b88c1c072bf1bd981cf
This commit is contained in:
@@ -198,7 +198,7 @@
|
||||
*/
|
||||
timeEnd(name) {
|
||||
const baseTime = this._baselines[name] || 0;
|
||||
const time = this.now() - baseTime;
|
||||
const time = Math.round(this.now() - baseTime) + 'ms';
|
||||
this.reporter(TIMING.TYPE, TIMING.CATEGORY, name, time);
|
||||
delete this._baselines[name];
|
||||
},
|
||||
|
||||
@@ -85,10 +85,10 @@ limitations under the License.
|
||||
nowStub.returns(3.123);
|
||||
element.timeEnd('foo');
|
||||
assert.isTrue(element.reporter.calledWithExactly(
|
||||
'timing-report', 'UI Latency', 'foo', 3.123
|
||||
'timing-report', 'UI Latency', 'foo', '3ms'
|
||||
));
|
||||
assert.isTrue(element.reporter.calledWithExactly(
|
||||
'timing-report', 'UI Latency', 'bar', 1
|
||||
'timing-report', 'UI Latency', 'bar', '1ms'
|
||||
));
|
||||
});
|
||||
|
||||
@@ -104,7 +104,7 @@ limitations under the License.
|
||||
sandbox.stub(element, 'now').returns(42);
|
||||
element.pluginsLoaded();
|
||||
assert.isTrue(element.defaultReporter.calledWithExactly(
|
||||
'timing-report', 'UI Latency', 'PluginsLoaded', 42
|
||||
'timing-report', 'UI Latency', 'PluginsLoaded', '42ms'
|
||||
));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user