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

core: Optimize asynchronous task executions ✈ #15715

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions core/gather/base-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import {
* @return {Promise<LH.BaseArtifacts>}
*/
async function getBaseArtifacts(resolvedConfig, driver, context) {
const BenchmarkIndex = await getBenchmarkIndex(driver.executionContext);
const {userAgent, product} = await getBrowserVersion(driver.defaultSession);
const [BenchmarkIndex, {userAgent, product}] = await Promise.all([
getBenchmarkIndex(driver.executionContext),
getBrowserVersion(driver.defaultSession),
]);

sanjaiyan-dev marked this conversation as resolved.
Show resolved Hide resolved
return {
// Meta artifacts.
Expand Down
6 changes: 4 additions & 2 deletions core/gather/gatherers/link-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ class LinkElements extends BaseGatherer {
*/
async getArtifact(context) {
const devtoolsLog = context.dependencies.DevtoolsLog;
const fromDOM = await LinkElements.getLinkElementsInDOM(context);
const fromHeaders = await LinkElements.getLinkElementsInHeaders(context, devtoolsLog);
const [fromDOM, fromHeaders] = await Promise.all([
LinkElements.getLinkElementsInDOM(context),
LinkElements.getLinkElementsInHeaders(context, devtoolsLog),
]);
const linkElements = fromDOM.concat(fromHeaders);
sanjaiyan-dev marked this conversation as resolved.
Show resolved Hide resolved

for (const link of linkElements) {
Expand Down
6 changes: 4 additions & 2 deletions core/gather/gatherers/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
*/
async getArtifact(context) {
const session = context.driver.defaultSession;
const {versions} = await serviceWorkers.getServiceWorkerVersions(session);
const {registrations} = await serviceWorkers.getServiceWorkerRegistrations(session);
const [{versions}, {registrations}] = await Promise.all([
serviceWorkers.getServiceWorkerVersions(session),
serviceWorkers.getServiceWorkerRegistrations(session),
]);

Check warning on line 25 in core/gather/gatherers/service-worker.js

View check run for this annotation

Codecov / codecov/patch

core/gather/gatherers/service-worker.js#L22-L25

Added lines #L22 - L25 were not covered by tests
sanjaiyan-dev marked this conversation as resolved.
Show resolved Hide resolved

return {
versions,
Expand Down