fix(benchpress): Allow ignoring navigationStart events in perflog metric. (#20312)
PR Close #20312
This commit is contained in:

committed by
Miško Hevery

parent
4064cbe945
commit
717ac5ac4d
@ -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 = [
|
||||
[
|
||||
|
Reference in New Issue
Block a user