Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --userTimingBlockList #2227

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/core/engine/command/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { timestamp as _timestamp } from '../../../support/engineUtils.js';
import { Video } from '../../../video/video.js';
import { pathToFolder } from '../../../support/pathToFolder.js';
import { setOrangeBackground } from '../../../video/screenRecording/setOrangeBackground.js';
import { filterAllowlisted } from '../../../support/userTiming.js';
import {
filterAllowlisted,
filterBlocklisted
} from '../../../support/userTiming.js';
import { isAndroidConfigured, Android } from '../../../android/index.js';
import { TCPDump } from '../../../support/tcpdump.js';
import { lcpHighlightScript as highlightLargestContentfulPaint } from './util/lcpHighlightScript.js';
Expand Down Expand Up @@ -643,6 +646,14 @@ export class Measure {
);
}

if (this.options.userTimingBlockList) {
filterBlocklisted(
this.result[this.numberOfMeasuredPages].browserScripts.timings
.userTimings,
this.options.userTimingAllowList
);
}

if (isAndroidConfigured(this.options) && this.options.processStartTime) {
const packageName =
this.options.browser === 'firefox'
Expand Down
4 changes: 4 additions & 0 deletions lib/support/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,10 @@ export function parseCommandLine() {
describe:
'All userTimings are captured by default this option takes a regex that will allow which userTimings to capture in the results.'
})
.option('userTimingBlockList', {
describe:
'All userTimings are captured by default this option takes a regex that will block some usertimings in the results.'
})
.option('headless', {
type: 'boolean',
default: false,
Expand Down
10 changes: 10 additions & 0 deletions lib/support/userTiming.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ export function filterAllowlisted(userTimings, allowlistRegex) {
allowed.test(measure.name)
);
}

export function filterBlocklisted(userTimings, blocklistRegex) {
const blocked = new RegExp(blocklistRegex);
userTimings.marks = userTimings.marks.filter(
mark => !blocked.test(mark.name)
);
userTimings.measures = userTimings.measures.filter(
measure => !blocked.test(measure.name)
);
}
Loading