Skip to content

Commit

Permalink
Add --enableVideoRun to get one extra run with a video and visual met…
Browse files Browse the repository at this point in the history
…rics
  • Loading branch information
soulgalore committed Jun 5, 2024
1 parent eaf66fd commit 740acc0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
39 changes: 26 additions & 13 deletions bin/browsertime.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,34 @@ async function run(urls, options) {
);
}

if (options.enableProfileRun) {
log.info('Make one extra run to collect trace information');
if (options.enableProfileRun || options.enableVideoRun) {
log.info('Make one extra run to collect trace/video information');
options.iterations = 1;
if (options.browser === 'firefox') {
options.firefox.geckoProfiler = true;
} else if (options.browser === 'chrome') {
options.chrome.timeline = true;
options.cpu = true;
options.chrome.enableTraceScreenshots = true;
options.chrome.traceCategory = [
'disabled-by-default-v8.cpu_profiler'
];
if (options.enableProfileRun) {
if (options.browser === 'firefox') {
options.firefox.geckoProfiler = true;
} else if (options.browser === 'chrome') {
options.chrome.timeline = true;
options.cpu = true;
options.chrome.enableTraceScreenshots = true;
options.chrome.traceCategory = [
'disabled-by-default-v8.cpu_profiler'
];
}
}
if (options.enableVideoRun) {
if (options.video === true) {
log.error(
'You can only configure video run if you do not collect any video'
);
// This is a hack to not get an error
options.video = false;
options.visualMetrics = false;
} else {
options.video = true;
options.visualMetrics = false;
}
}
options.video = false;
options.visualMetrics = false;
const traceEngine = new Engine(options);
await traceEngine.start();
await traceEngine.runMultiple(urls, scriptsByCategory);
Expand Down
5 changes: 5 additions & 0 deletions lib/support/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,11 @@ export function parseCommandLine() {
describe:
'Make one extra run that collects the profiling trace log (no other metrics is collected). For Chrome it will collect the timeline trace, for Firefox it will get the Geckoprofiler trace. This means you do not need to get the trace for all runs and can skip the overhead it produces.'
})
.option('enableVideoRun', {
type: 'boolean',
describe:
'Make one extra run that collects video and visual metrics. This means you can do your runs with --visualMetrics true --video false --enableVideoRun true to collect visual metrics from all runs and save a video from the profile/video run. If you run it together with --enableProfileRun it will also collect profiling trace.'
})
.option('video', {
type: 'boolean',
describe:
Expand Down

0 comments on commit 740acc0

Please sign in to comment.