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

Make sure the extra run happens after the engine stopped #2140

Merged
merged 1 commit into from
Jun 7, 2024
Merged
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
69 changes: 35 additions & 34 deletions bin/browsertime.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,40 +123,6 @@ async function run(urls, options) {
);
}

if (options.enableProfileRun || options.enableVideoRun) {
log.info('Make one extra run to collect trace/video information');
options.iterations = 1;
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 = true;
}
}
const traceEngine = new Engine(options);
await traceEngine.start();
await traceEngine.runMultiple(urls, scriptsByCategory);
await traceEngine.stop();
}

await Promise.all(saveOperations);

const resultDirectory = relative(process.cwd(), storageManager.directory);
Expand Down Expand Up @@ -186,6 +152,41 @@ async function run(urls, options) {
process.exitCode = 1;
}
}

if (options.enableProfileRun || options.enableVideoRun) {
log.info('Make one extra run to collect trace/video information');
options.iterations = 1;
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 = true;
}
}
const traceEngine = new Engine(options);
await traceEngine.start();
await traceEngine.runMultiple(urls, scriptsByCategory);
await traceEngine.stop();
log.info('Extra run finished');
}
} catch (error) {
log.error('Error running browsertime', error);
process.exitCode = 1;
Expand Down
Loading