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

fix(performance): cache isolatedHandle #12150

Merged
merged 3 commits into from Apr 19, 2024
Merged

Conversation

Lightning00Blade
Copy link
Collaborator

No description provided.

@OrKoN
Copy link
Collaborator

OrKoN commented Mar 26, 2024

preformence -> performance

@Lightning00Blade Lightning00Blade changed the title fix(preformence): cache isolatedHandle fix(performance): cache isolatedHandle Mar 26, 2024
@OrKoN
Copy link
Collaborator

OrKoN commented Mar 26, 2024

@Lightning00Blade pls fix the formatting/docs

@OrKoN
Copy link
Collaborator

OrKoN commented Mar 26, 2024

@Lightning00Blade do you have any numbers for performance?

@Lightning00Blade
Copy link
Collaborator Author

I have not gather data, will do and report it back here.

@Lightning00Blade
Copy link
Collaborator Author

@OrKoN

Current 94ms, 87ms, 93ms, 102ms. 96ms 
Last release: 92ms, 94ms, 117ms, 94ms, 118ms 
import { launch } from "puppeteer";

(async () => {
  const browser = await launch({
    headless: true,
  });

  const page = await browser.newPage();

  await page.setContent(`
    <html>
      <head>
        <title>Hello, world!</title>
      </head>
      <body>
        <h1>Hello, <span>world</span>!</h1>
      </body>
    </html>
  `);
  const start = performance.now();
  const element = await page.$("h1");
  const element2 = await element.$("span");
  console.log(await element.isVisible());
  console.log(await element2.isVisible());

  await element.screenshot({
    path: "screenshot.png",
  });
  const end = performance.now();
  console.log("Screenshot taken in", end - start, "ms");

  await page.screenshot();
  await browser.close();
})();

So the more you use an ElementHandle the better the performence.

@OrKoN
Copy link
Collaborator

OrKoN commented Apr 2, 2024

@Lightning00Blade could you measure it for like 100-1000 ElementHandle operations to get a number % for the improvement?

@Lightning00Blade
Copy link
Collaborator Author

What should the test do exactly, we need to trigger the decorator so we need to do X operations?

@OrKoN
Copy link
Collaborator

OrKoN commented Apr 2, 2024

@Lightning00Blade it could be anything that something that can clearly say by how much it is improved? Or perhaps do more runs and get the average.

@Lightning00Blade
Copy link
Collaborator Author

Lightning00Blade commented Apr 10, 2024

Previous version with average of 34.23254930973053 ms.
After change with average of 30.94756257534027 ms.

Test code with 10 iterations over it.

import { launch } from "puppeteer";

(async () => {
  const browser = await launch({
    headless: true,
  });

  const page = await browser.newPage();

  await page.setContent(`
    <html>
      <head>
        <title>Hello, world!</title>
      </head>
      <body>
        <h1>Hello, <span>world</span>!</h1>
      </body>
    </html>
  `);
  const start = performance.now();
  const element = await page.$("h1");
  await element.$("span");
  await element.isVisible();
  await element.focus();
  await element.click();

  const end = performance.now();
  console.log("Run completed in", end - start, "ms");

  await browser.close();
})();

@Lightning00Blade Lightning00Blade force-pushed the cache-isolated-hanle branch 3 times, most recently from 8c7adea to 021148b Compare April 15, 2024 11:56
@OrKoN OrKoN force-pushed the main branch 5 times, most recently from 2ff1e4f to e0932e5 Compare April 16, 2024 09:37
dependabot bot and others added 3 commits April 19, 2024 11:00
… in the all group (#12273)

Bumps the all group with 1 update:
[peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request).

Updates `peter-evans/create-pull-request` from 6.0.2 to 6.0.3
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/peter-evans/create-pull-request/releases">peter-evans/create-pull-request's
releases</a>.</em></p>
<blockquote>
<h2>Create Pull Request v6.0.3</h2>
<p>⚡ Improves performance of the <code>push-to-fork</code> feature.</p>
<h2>What's Changed</h2>
<ul>
<li>build(deps-dev): bump <code>@​types/node</code> from 18.19.23 to
18.19.25 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/peter-evans/create-pull-request/pull/2826">peter-evans/create-pull-request#2826</a></li>
<li>build(deps-dev): bump <code>@​types/node</code> from 18.19.25 to
18.19.26 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/peter-evans/create-pull-request/pull/2831">peter-evans/create-pull-request#2831</a></li>
<li>build(deps-dev): bump <code>@​types/node</code> from 18.19.26 to
18.19.28 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/peter-evans/create-pull-request/pull/2836">peter-evans/create-pull-request#2836</a></li>
<li>build(deps-dev): bump <code>@​types/node</code> from 18.19.28 to
18.19.31 by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a> in <a
href="https://redirect.github.com/peter-evans/create-pull-request/pull/2842">peter-evans/create-pull-request#2842</a></li>
<li>fix: drop unnecessary fetch with unshallow on push-to-fork by <a
href="https://github.com/peter-evans"><code>@​peter-evans</code></a> in
<a
href="https://redirect.github.com/peter-evans/create-pull-request/pull/2849">peter-evans/create-pull-request#2849</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/peter-evans/create-pull-request/compare/v6.0.2...v6.0.3">https://github.com/peter-evans/create-pull-request/compare/v6.0.2...v6.0.3</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/peter-evans/create-pull-request/commit/c55203cfde3e5c11a452d352b4393e68b85b4533"><code>c55203c</code></a>
fix: drop unnecessary fetch with unshallow on push-to-fork (<a
href="https://redirect.github.com/peter-evans/create-pull-request/issues/2849">#2849</a>)</li>
<li><a
href="https://github.com/peter-evans/create-pull-request/commit/6ce4eca6b6db0ff4f4d1b542dce50e785446dc27"><code>6ce4eca</code></a>
build(deps-dev): bump <code>@​types/node</code> from 18.19.28 to
18.19.31 (<a
href="https://redirect.github.com/peter-evans/create-pull-request/issues/2842">#2842</a>)</li>
<li><a
href="https://github.com/peter-evans/create-pull-request/commit/36ef0ed92fad84020ab7eb31a226f860a2b8a886"><code>36ef0ed</code></a>
build(deps-dev): bump <code>@​types/node</code> from 18.19.26 to
18.19.28 (<a
href="https://redirect.github.com/peter-evans/create-pull-request/issues/2836">#2836</a>)</li>
<li><a
href="https://github.com/peter-evans/create-pull-request/commit/8500972a1322d52aebd0e3050bc201599f71661f"><code>8500972</code></a>
build(deps-dev): bump <code>@​types/node</code> from 18.19.25 to
18.19.26 (<a
href="https://redirect.github.com/peter-evans/create-pull-request/issues/2831">#2831</a>)</li>
<li><a
href="https://github.com/peter-evans/create-pull-request/commit/bda5ade93c911e31761cd3de26f6df3d5b00f88f"><code>bda5ade</code></a>
build(deps-dev): bump <code>@​types/node</code> from 18.19.23 to
18.19.25 (<a
href="https://redirect.github.com/peter-evans/create-pull-request/issues/2826">#2826</a>)</li>
<li>See full diff in <a
href="https://github.com/peter-evans/create-pull-request/compare/70a41aba780001da0a30141984ae2a0c95d8704e...c55203cfde3e5c11a452d352b4393e68b85b4533">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=peter-evans/create-pull-request&package-manager=github_actions&previous-version=6.0.2&new-version=6.0.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@Lightning00Blade Lightning00Blade merged commit 9a17ec3 into main Apr 19, 2024
38 checks passed
@Lightning00Blade Lightning00Blade deleted the cache-isolated-hanle branch April 19, 2024 09:55
@release-please release-please bot mentioned this pull request Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants