diff --git a/bin/browsertime.js b/bin/browsertime.js index 7258afd15..b6d6f8b93 100755 --- a/bin/browsertime.js +++ b/bin/browsertime.js @@ -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); diff --git a/lib/support/cli.js b/lib/support/cli.js index bad1c3479..2214d191c 100644 --- a/lib/support/cli.js +++ b/lib/support/cli.js @@ -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: