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

How much faster is Electron compared to PhantomJS? #484

Closed
Robert-Ernst opened this issue Feb 16, 2016 · 7 comments
Closed

How much faster is Electron compared to PhantomJS? #484

Robert-Ernst opened this issue Feb 16, 2016 · 7 comments

Comments

@Robert-Ernst
Copy link
Contributor

You state:

Under the covers it uses Electron, which is similar to PhantomJS but faster and more modern.

Can you show us some proof like benchmarks or documentation to proof that?

Greets

@matthewmueller
Copy link
Contributor

Certainly. Here's some results from awhile back. This is from an old email.


Phantom has been very slow for us, and so I was experimenting around with using Electron as a web driver in instead. It turns out Electron is quite a bit faster. Here's some of the benchmarks for selecting document.title:

Nightmare (via Phantom):

Google: 2064ms
Yahoo: 4059ms
CNN: 8658ms

Nightmare (via Electron):

Google: 866ms
Yahoo: 1862ms
CNN: 2729ms

@boxtown
Copy link

boxtown commented Mar 13, 2017

@matthewmueller You wouldn't happen to have the benchmarking code would you? I did some basic benchmarking on a 2016 Macbook Pro between Nightmare (using Electron) and Capybara with PoltergeistJS (Ruby interface to PhantomJS), and Nightmare is usually around 1.5x - 2.5x slower for me

@abacaj
Copy link

abacaj commented Mar 17, 2017

It is unclear to me what those benchmark numbers even mean or if they are even accurate...

I ran Nightmare locally and Electron takes 2300ms~ to get page title from google.com, this is using the latest build available on NPM.

A truly fast headless browser - zombie.js, the results are very promising: 700ms~ to get page title from google.com

@matthewmueller
Copy link
Contributor

matthewmueller commented Mar 17, 2017

@boxtown weird maybe phantom has improved a lot since these were run. Don't have the old code on me, but you can probably just download nightmare 1.x and nightmare 2.x to run them side by side.

@abacaj if you can use a headless browser with a fake DOM implementation, then you should. Last I checked zombie was still using jsdom, you could improve that further with cheerio. Nightmare is built for sites that are javascript heavy and need to be able to run the client-side javascript code.

@laggingreflex
Copy link

https://github.com/laggingreflex/scrapers-benchmarks

Run 1 { request: 747, zombie: 2895, phantom: 4406, nightmare: 7854 }
Run 2 { request: 627, zombie: 2008, phantom: 4486, nightmare: 7522 }
Run 3 { request: 620, zombie: 1807, phantom: 4736, nightmare: 11186 }
Run 4 { request: 631, zombie: 2025, phantom: 4810, nightmare: 8878 }
Run 5 { request: 615, zombie: 2122, phantom: 4864, nightmare: 7726 }
Average: { request: 648, zombie: 2171, phantom: 4660, nightmare: 8633 }

@kmiterror
Copy link

kmiterror commented Dec 28, 2017

@laggingreflex I get quite different results.

Run 1 { request: 229, zombie: 629, puppeteer: 3792, phantom: 6734, nightmare: 2942 }
Run 2 { request: 188, zombie: 657, puppeteer: 1040, phantom: 6707, nightmare: 2183 }
Run 3 { request: 185, zombie: 523, puppeteer: 1295, phantom: 6723, nightmare: 2184 }
Run 4 { request: 183, zombie: 502, puppeteer: 1227, phantom: 6706, nightmare: 2198 }
Run 5 { request: 189, zombie: 542, puppeteer: 1238, phantom: 6744, nightmare: 2199 }
Average: { request: 194, zombie: 570, puppeteer: 1718, phantom: 6722, nightmare: 2341 }

request, zombie and nightmare are around 3x-4x faster on my machine which seems consistent. But phantom is slower by around 50%, which doesn't make sense.

What could be the reason?
Some phantomjs bug/glitch with drivers/system on my machine?
Different nodejs version?
Tested page has been modified in some way?

My results are closer to what @matthewmueller posted, which is: nightmare is around 3x faster than phantom.

Also I believe that request is not a full stack browser. As it is described on github

Request - Simplified HTTP client.
Request is designed to be the simplest way possible to make http calls.

So it should not be benchmarked against full-stack headless browsers.

Final results
Zombie seems like a fastest in the pack, but also this benchmark is a very basic test (opening a initial google.com page) Running tests on some js heavy page could give very different results.

@matthewmueller
Copy link
Contributor

matthewmueller commented Dec 28, 2017

Just want to point out that Zombie being faster is to be expected. It uses JSDOM underneath, so if you can get away with using Zombie, you should. The problem is that any JS-heavy website wouldn't work with Zombie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants