Skip to content

Commit

Permalink
#257 - implement whitelist option for userTimings
Browse files Browse the repository at this point in the history
  • Loading branch information
beenanner committed Jan 25, 2017
1 parent c3f86fd commit 5d6c987
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/core/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,17 @@ class Engine {
merge({}, syncScripts, asyncScripts));
})
.then((result) => {
const userTimingWhitelistRegex = new RegExp(options.userTimingWhitelist);
if (userTimingWhitelistRegex) {
let userTimingMarks = result.timings.userTimings.marks;
result.timings.userTimings.marks = userTimingMarks.filter((mark) => {
return userTimingWhitelistRegex.exec(mark.name) !== null;
}, {});
let userTimingMeasurements = result.timings.userTimings.measures;
result.timings.userTimings.measures = userTimingMeasurements.filter((measure) => {
return userTimingWhitelistRegex.exec(measure.name) !== null;
}, {});
}
return {
browserScripts: result,
extraJson: {}
Expand Down
3 changes: 3 additions & 0 deletions lib/support/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ module.exports.parseCommandLine = function parseCommandLine() {
.option('preURL', {
describe: 'A URL that will be accessed first by the browser before the URL that you wanna analyze. Use it to fill the cache.'
})
.option('userTimingWhitelist', {
describe: 'A regex that will whitelist which userTimings to capture in results.'
})
.count('verbose')
.string('_')
.help('h')
Expand Down

0 comments on commit 5d6c987

Please sign in to comment.