Skip to content

Commit

Permalink
Add --userTimingBlockList sitespeedio/sitespeed.io#4344 (#2227)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore authored Dec 22, 2024
1 parent db8390e commit 5b140c4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
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)
);
}

0 comments on commit 5b140c4

Please sign in to comment.