fix(benchpress): update the check for start and end events (#42085)

* recently, performance events started showing up with a -bpstart and -bpend
  suffix to indicate their being the start and end events for our performance
  testing. to fix this, we added an additional check for those suffixes in
  addition to the old checks.

PR Close #42085
This commit is contained in:
wagnermaciel 2021-05-13 13:29:38 -07:00 committed by Andrew Scott
parent fdb3d3076e
commit 2e7eb270df
1 changed files with 14 additions and 2 deletions

View File

@ -238,13 +238,25 @@ export class PerflogMetric extends Metric {
events.forEach((event) => { events.forEach((event) => {
const ph = event['ph']; const ph = event['ph'];
const name = event['name']; const name = event['name'];
if (ph === 'B' && name === markName) {
// Here we are determining if this is the event signaling the start or end of our performance
// testing (this is triggered by us calling #timeBegin and #timeEnd).
//
// Previously, this was done by checking that the event name matched our mark name and that
// the phase was either "B" or "E" ("begin" or "end"). However, for some reason now this is
// showing up as "-bpstart" and "-bpend" ("benchpress start/end"), which is what one would
// actually expect since that is the mark name used in ChromeDriverExtension - see the
// #timeBegin and #timeEnd implementations in chrome_driver_extension.ts. We are not sure why
// the markName didn't show up with the "-bp(start/end)" suffix before.
const isStartEvent = (ph === 'B' && name === markName) || name === markName + '-bpstart';
const isEndEvent = (ph === 'E' && name === markName) || name === markName + '-bpend';
if (isStartEvent) {
markStartEvent = event; markStartEvent = event;
} else if (ph === 'I' && name === 'navigationStart' && !this._ignoreNavigation) { } else if (ph === 'I' && name === 'navigationStart' && !this._ignoreNavigation) {
// if a benchmark measures reload of a page, use the last // if a benchmark measures reload of a page, use the last
// navigationStart as begin event // navigationStart as begin event
markStartEvent = event; markStartEvent = event;
} else if (ph === 'E' && name === markName) { } else if (isEndEvent) {
markEndEvent = event; markEndEvent = event;
} }
}); });