Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Lightpanda browser, but the code is not publicly available yet.
### Running the benchmark

The `puppeteer/cdp.js` benchmark accepts multiple env vars to be configured.
* `BROWSER_ADDRESS` is the address of the running browser listening the CDP protocol, by default `http://127.0.0.1:9222`.
* `BROWSER_ADDRESS` is the address of the running browser listening the CDP protocol, by default `ws://127.0.0.1:9222`.
* `BASE_URL` is the base url of the running web reser to request, by default `http://127.0.0.1:1234`.
* `RUNS` is the number of pages loaded by the benchmark, default is `100`.

Expand All @@ -193,7 +193,7 @@ $ /usr/bin/time -v google-chrome --headless=new --remote-debugging-port=9222

Then you can run the benchmark.
```console
$ npm run bench-puppeteer-cdp
$ BROWSER_ADDRESS=http://127.0.0.1:9222 npm run bench-puppeteer-cdp

> demo@1.0.0 bench-puppeteer-cdp
> node puppeteer/cdp.js
Expand Down
2 changes: 1 addition & 1 deletion playwright/cdp.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { chromium } from 'playwright';

// browserAddress
const browserAddress = process.env.BROWSER_ADDRESS ? process.env.BROWSER_ADDRESS : 'http://127.0.0.1:9222';
const browserAddress = process.env.BROWSER_ADDRESS ? process.env.BROWSER_ADDRESS : 'ws://127.0.0.1:9222';

// web serveur url
const baseURL = process.env.BASE_URL ? process.env.BASE_URL : 'http://127.0.0.1:1234';
Expand Down
13 changes: 9 additions & 4 deletions puppeteer/cdp.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import puppeteer from 'puppeteer-core';

// ws address
const browserAddress = process.env.BROWSER_ADDRESS ? process.env.BROWSER_ADDRESS : 'http://127.0.0.1:9222';
const browserAddress = process.env.BROWSER_ADDRESS ? process.env.BROWSER_ADDRESS : 'ws://127.0.0.1:9222';

// web serveur url
const baseURL = process.env.BASE_URL ? process.env.BASE_URL : 'http://127.0.0.1:1234';
Expand All @@ -31,9 +31,14 @@ let metrics = [];

(async () => {
// Connect to the browser and open a new blank page
const browser = await puppeteer.connect({
browserURL: browserAddress,
});
let opts = {};
if (browserAddress.substring(0, 5) == 'ws://') {
opts.browserWSEndpoint = browserAddress;
} else {
opts.browserURL = browserAddress;
}

const browser = await puppeteer.connect(opts);

for (var run = 0; run<runs; run++) {
// measure run time.
Expand Down