Why this pattern is so much faster in Chrome/V8?

12 views
Skip to first unread message

arbingersys

unread,
Jun 25, 2010, 1:08:35 PM6/25/10
to v8-users
Hi, in implementing the following JavaScript pattern ...

function doSomething (callbackFn [, additional arguments]) {
// Initialize a few things here...
(function () {
// Do a little bit of work here...
if (termination condition) {
// We are done
callbackFn();
} else {
// Process next chunk
setTimeout(arguments.callee, 0);
}
})();
}

... over a large dataset (> 5MB), there is a huge performance
difference between Chrome and the other browsers. I know V8 is
generally faster than the other engines, but I'm curious why it's so
much faster for this particular pattern?

For a detailed explanation of what I was doing, you can read the
following post on my blog --

http://www.arbingersys.com/2010/06/im-believer-chrome-javascript-fast.html

I'd love to understand this better. Thanks, James

Erik Kay

unread,
Jun 25, 2010, 3:29:08 PM6/25/10
to v8-u...@googlegroups.com
Read this post for more details:
http://www.belshe.com/2010/06/04/chrome-cranking-up-the-clock/

Most of the time delta is almost certainly due to Chrome's setTimeout implementation.  The amount of work you do inside the loop would be affected by the JS engine and that probably explains most of the extra time that IE8 is taking over firefox.

Erik



arbingersys

unread,
Jun 25, 2010, 5:33:14 PM6/25/10
to v8-users
Thanks for the link. Excellent article. James

On Jun 25, 1:29 pm, Erik Kay <erik...@chromium.org> wrote:
> Read this post for more details:http://www.belshe.com/2010/06/04/chrome-cranking-up-the-clock/

...
Reply all
Reply to author
Forward
0 new messages