fix(benchpress): Allow ignoring navigationStart events in perflog metric. (#20312)

PR Close #20312
This commit is contained in:
Michael Giambalvo
2017-11-09 12:51:17 -08:00
committed by Miško Hevery
parent 4064cbe945
commit 717ac5ac4d
2 changed files with 32 additions and 6 deletions

View File

@ -18,12 +18,13 @@ export function main() {
function createMetric(
perfLogs: PerfLogEvent[], perfLogFeatures: PerfLogFeatures,
{microMetrics, forceGc, captureFrames, receivedData, requestCount}: {
{microMetrics, forceGc, captureFrames, receivedData, requestCount, ignoreNavigation}: {
microMetrics?: {[key: string]: string},
forceGc?: boolean,
captureFrames?: boolean,
receivedData?: boolean,
requestCount?: boolean
requestCount?: boolean,
ignoreNavigation?: boolean
} = {}): Metric {
commandLog = [];
if (!perfLogFeatures) {
@ -59,6 +60,9 @@ export function main() {
if (requestCount != null) {
providers.push({provide: Options.REQUEST_COUNT, useValue: requestCount});
}
if (ignoreNavigation != null) {
providers.push({provide: PerflogMetric.IGNORE_NAVIGATION, useValue: ignoreNavigation});
}
return Injector.create(providers).get(PerflogMetric);
}
@ -185,6 +189,22 @@ export function main() {
});
}));
it('should ignore navigationStart if ignoreNavigation is set',
inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
const events = [[
eventFactory.markStart('benchpress0', 0), eventFactory.start('script', 4),
eventFactory.end('script', 6), eventFactory.instant('navigationStart', 7),
eventFactory.start('script', 8), eventFactory.end('script', 9),
eventFactory.markEnd('benchpress0', 10)
]];
const metric = createMetric(events, null !, {ignoreNavigation: true});
metric.beginMeasure().then((_) => metric.endMeasure(false)).then((data) => {
expect(data['scriptTime']).toBe(3);
async.done();
});
}));
it('should restart timing', inject([AsyncTestCompleter], (async: AsyncTestCompleter) => {
const events = [
[