Skip to content

Commit 4b27911

Browse files
Merge pull request #14 from lightpanda-io/lpd-cdp
Update becnhmark for Lightpanda CDP
2 parents c1bc532 + 7e46a21 commit 4b27911

File tree

5 files changed

+137
-45
lines changed

5 files changed

+137
-45
lines changed

README.md

Lines changed: 137 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ $ apt install time hyperfine
3939
```
4040

4141
You have also to install [Google Chrome](https://www.google.com/chrome/) and
42-
Lightpanda browser, but the code is not publicly available yet.
42+
[Lightpanda browser](https://github.com/lightpanda-io/browser/releases/tag/nightly).
4343

4444
### Demo web page
4545

@@ -65,28 +65,30 @@ This bench is a very basic test to compare the two software.
6565
We start the browser and request the fake web page once with full JS execution. The final DOMTree is
6666
rendered in stdout.
6767

68-
We use Google Chrome version 122.0.6261.94.
68+
We use Google Chrome version 130.0.6723.58.
6969

7070
```console
7171
$ google-chrome --version
72-
Google Chrome 122.0.6261.94
72+
Google Chrome 130.0.6723.58
7373
```
7474

75+
And Lightpanda commit [1e64513c16acce6c4d58a1b3c32b0e2d3c8201d2](https://github.com/lightpanda-io/browser/commit/1e64513c16acce6c4d58a1b3c32b0e2d3c8201d2).
76+
7577
### Execution time
7678

7779
```console
78-
$ hyperfine --warmup 3 --runs 20 --shell=none "google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:1234/campfire-commerce/" "./browsercore-get --dump http://127.0.0.1:1234/campfire-commerce/"
79-
Benchmark 1: google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:1234/campfire-commerce/
80-
Time (mean ± σ): 556.7 ms ± 10.2 ms [User: 360.8 ms, System: 170.6 ms]
81-
Range (min … max): 538.2 ms … 571.6 ms 20 runs
80+
$ hyperfine --warmup 3 --runs 20 --shell=none "google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:124/campfire-commerce/" "./lightpanda --dump http://127.0.0.1:1234/campfire-commerce/"
81+
Benchmark 1: google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:124/campfire-commerce/
82+
Time (mean ± σ): 618.9 ms ± 12.8 ms [User: 363.0 ms, System: 162.0 ms]
83+
Range (min … max): 598.2 ms … 659.2 ms 20 runs
8284

83-
Benchmark 2: ./browsercore-get --dump http://127.0.0.1:1234/campfire-commerce/
84-
Time (mean ± σ): 8.6 ms ± 0.2 ms [User: 5.0 ms, System: 3.2 ms]
85-
Range (min … max): 8.3 ms … 9.0 ms 20 runs
85+
Benchmark 2: ./lightpanda --dump http://127.0.0.1:1234/campfire-commerce/
86+
Time (mean ± σ): 9.9 ms ± 0.3 ms [User: 5.8 ms, System: 3.7 ms]
87+
Range (min … max): 9.3 ms … 10.4 ms 20 runs
8688

8789
Summary
88-
'./browsercore-get --dump http://127.0.0.1:1234/campfire-commerce/' ran
89-
64.48 ± 1.74 times faster than 'google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:1234/campfire-commerce/'
90+
'./lightpanda --dump http://127.0.0.1:1234/campfire-commerce/' ran
91+
62.58 ± 2.32 times faster than 'google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:124/campfire-commerce/'
9092
```
9193

9294
![aws.m5 hyperfine](./img/aws_m5_hyperfine.png)
@@ -96,47 +98,48 @@ Summary
9698
```console
9799
$ /usr/bin/time -v google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:1234/campfire-commerce/
98100
Command being timed: "google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:1234/campfire-commerce/"
99-
User time (seconds): 0.38
100-
System time (seconds): 0.14
101-
Percent of CPU this job got: 96%
102-
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.55
101+
User time (seconds): 0.34
102+
System time (seconds): 0.19
103+
Percent of CPU this job got: 94%
104+
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.57
103105
Average shared text size (kbytes): 0
104106
Average unshared data size (kbytes): 0
105107
Average stack size (kbytes): 0
106108
Average total size (kbytes): 0
107-
Maximum resident set size (kbytes): 169924
109+
Maximum resident set size (kbytes): 174096
108110
Average resident set size (kbytes): 0
109-
Major (requiring I/O) page faults: 5
110-
Minor (reclaiming a frame) page faults: 20535
111-
Voluntary context switches: 2664
112-
Involuntary context switches: 1655
111+
Major (requiring I/O) page faults: 17
112+
Minor (reclaiming a frame) page faults: 20609
113+
Voluntary context switches: 2563
114+
Involuntary context switches: 1618
113115
Swaps: 0
114-
File system inputs: 0
115-
File system outputs: 1624
116+
File system inputs: 1048
117+
File system outputs: 4576
116118
Socket messages sent: 0
117119
Socket messages received: 0
118120
Signals delivered: 0
119121
Page size (bytes): 4096
120122
Exit status: 0
123+
121124
```
122125

123126
```console
124-
$ /usr/bin/time -v ./browsercore-get --dump http://127.0.0.1:1234/campfire-commerce/
125-
Command being timed: "./browsercore-get --dump http://127.0.0.1:1234/campfire-commerce/"
127+
$ /usr/bin/time -v ./lightpanda --dump http://127.0.0.1:1234/campfire-commerce/
128+
Command being timed: "./lightpanda --dump http://127.0.0.1:1234/campfire-commerce/"
126129
User time (seconds): 0.00
127130
System time (seconds): 0.00
128-
Percent of CPU this job got: 100%
131+
Percent of CPU this job got: 92%
129132
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.01
130133
Average shared text size (kbytes): 0
131134
Average unshared data size (kbytes): 0
132135
Average stack size (kbytes): 0
133136
Average total size (kbytes): 0
134-
Maximum resident set size (kbytes): 14348
137+
Maximum resident set size (kbytes): 21276
135138
Average resident set size (kbytes): 0
136139
Major (requiring I/O) page faults: 0
137-
Minor (reclaiming a frame) page faults: 751
140+
Minor (reclaiming a frame) page faults: 925
138141
Voluntary context switches: 6
139-
Involuntary context switches: 70
142+
Involuntary context switches: 11
140143
Swaps: 0
141144
File system inputs: 0
142145
File system outputs: 0
@@ -147,60 +150,149 @@ $ /usr/bin/time -v ./browsercore-get --dump http://127.0.0.1:1234/campfire-comme
147150
Exit status: 0
148151
```
149152

150-
## Multiple requests using Playwright
153+
## Multiple requests using Puppeteer
151154

152155
We compare now multiple page loads and js evaluations using
153-
[Playwright](https://playwright.dev), which connects to the browser using CDP (Chrome Debug Protocol).
156+
[Puppeteer](https://https://pptr.dev/), which connects to the browser using CDP
157+
(Chrome Debug Protocol).
154158

155159
### Dependencies
156160

157161
To run the benchmark, you need ti install [nodejs](https://nodejs.org/en/download).
158162

159163
Once `nodejs` is installed, please run a `npm install` to install nodejs
160-
dependencies, mainly Playwright.
164+
dependencies, mainly Puppeteer.
161165

162166
You have also to install [Google Chrome](https://www.google.com/chrome/) and
163167
Lightpanda browser, but the code is not publicly available yet.
164168

165169
### Running the benchmark
166170

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

172-
`npm run bench-playwright-cdp` starts a playwright process
176+
`npm run bench-puppeteer-cdp` starts a Puppeteer process
173177
instance and load the page to extract data 100 times.
174178

175179
```console
176-
$ npm run bench-playwright-cdp
180+
$ npm run bench-puppeteer-cdp
177181
```
178182

179183
### Results
180184

181185
**Google Chrome**
182186

183-
We use Google Chrome version 123.0.6312.105.
187+
We use Google Chrome version 130.0.6723.58.
184188

185189
You have to start the browser first.
186190
```console
187-
$ google-chrome --headless=new --disable-gpu --remote-debugging-port=9222
191+
$ /usr/bin/time -v google-chrome --headless=new --remote-debugging-port=9222
188192
```
189193

190194
Then you can run the benchmark.
191195
```console
192-
$ npm run bench-playwright-cdp
196+
$ npm run bench-puppeteer-cdp
193197

194-
> [email protected] bench-playwright-cdp
195-
> node playwright/cdp.js
198+
> [email protected] bench-puppeteer-cdp
199+
> node puppeteer/cdp.js
196200

197201
................................................................................
198202
....................
199203
total runs 100
200-
total duration (ms) 18792
201-
avg run duration (ms) 184
202-
min run duration (ms) 168
203-
max run duration (ms) 323
204+
total duration (ms) 25218
205+
avg run duration (ms) 248
206+
min run duration (ms) 216
207+
max run duration (ms) 451
208+
```
209+
210+
![aws.m5 Puppeteer with Google Chrome](./img/aws_m5_puppeteer_chrome.png)
211+
212+
```console
213+
Command being timed: "google-chrome --headless=new --remote-debugging-port=9222"
214+
User time (seconds): 16.19
215+
System time (seconds): 6.59
216+
Percent of CPU this job got: 41%
217+
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:54.51
218+
Average shared text size (kbytes): 0
219+
Average unshared data size (kbytes): 0
220+
Average stack size (kbytes): 0
221+
Average total size (kbytes): 0
222+
Maximum resident set size (kbytes): 207828
223+
Average resident set size (kbytes): 0
224+
Major (requiring I/O) page faults: 138
225+
Minor (reclaiming a frame) page faults: 265165
226+
Voluntary context switches: 143625
227+
Involuntary context switches: 82912
228+
Swaps: 0
229+
File system inputs: 35680
230+
File system outputs: 169688
231+
Socket messages sent: 0
232+
Socket messages received: 0
233+
Signals delivered: 0
234+
Page size (bytes): 4096
235+
Exit status: 0
236+
```
237+
238+
**Lightpanda browser**
239+
240+
We use Lightpanda commit [1e64513c16acce6c4d58a1b3c32b0e2d3c8201d2](https://github.com/lightpanda-io/browser/commit/1e64513c16acce6c4d58a1b3c32b0e2d3c8201d2).
241+
242+
You have to start the Lightpanda Gateway.
243+
```console
244+
./gateway
204245
```
205246

206-
![aws.m5 Playwright with Google Chrome](./img/aws_m5_playwright_chrome.png)
247+
And Lightpanda browser itself.
248+
```console
249+
/usr/bin/time -v ./lightpanda
250+
```
251+
252+
Then you can run the benchmark.
253+
```console
254+
$ npm run bench-puppeteer-cdp
255+
256+
> [email protected] bench-puppeteer-cdp
257+
> node puppeteer/cdp.js
258+
259+
................................................................................
260+
....................
261+
total runs 100
262+
total duration (ms) 3456
263+
avg run duration (ms) 32
264+
min run duration (ms) 23
265+
max run duration (ms) 105
266+
```
267+
268+
![aws.m5 Puppeteer with Lightpanda browser](./img/aws_m5_puppeteer_lightpanda.png)
269+
270+
```console
271+
Command being timed: "./lightpanda"
272+
User time (seconds): 41.78
273+
System time (seconds): 14.15
274+
Percent of CPU this job got: 99%
275+
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:56.14
276+
Average shared text size (kbytes): 0
277+
Average unshared data size (kbytes): 0
278+
Average stack size (kbytes): 0
279+
Average total size (kbytes): 0
280+
Maximum resident set size (kbytes): 100940
281+
Average resident set size (kbytes): 0
282+
Major (requiring I/O) page faults: 0
283+
Minor (reclaiming a frame) page faults: 29326
284+
Voluntary context switches: 235
285+
Involuntary context switches: 4099
286+
Swaps: 0
287+
File system inputs: 0
288+
File system outputs: 0
289+
Socket messages sent: 0
290+
Socket messages received: 0
291+
Signals delivered: 0
292+
Page size (bytes): 4096
293+
Exit status: 0
294+
```
295+
296+
---
297+
298+
Console images generated with [Carbon](https://carbon.now.sh).

img/aws_m5_hyperfine.png

9.03 KB
Loading

img/aws_m5_playwright_chrome.png

-144 KB
Binary file not shown.

img/aws_m5_puppeteer_chrome.png

137 KB
Loading
137 KB
Loading

0 commit comments

Comments
 (0)