Friday, October 12th, 2007

Evaulate Low Level JavaScript Performance Characteristics

Category: Performance

Bob Buffone (Nexaweb, XAP, and a lot more) has created an application to test JavaScript performance. You can run the app in various browsers to compare the results.

Bob has done that work for you though, and has documented his findings which has him concluding that the general ranking is Safari, Firefox, IE.

JS Perf

Posted by Dion Almaer at 7:40 am

1.3 rating from 344 votes


Comments feed TrackBack URI

Hey where’s Opera? I’m not particularly a fan, but they do claim to be pretty speedy. A recent trail of Opera Mobile (Pocket PC) seems a lot slower than the built in Pocket IE, admittedly with a significant difference in features.

Comment by David Carrington — October 12, 2007

Hey man, FYI, you misspelled “evaluate”…

Comment by Matthew Foley — October 12, 2007

They didn’t test Opera, because he’s never seen anyone using it. However, I’ve just run the tests on it on my machine, and it’s a lot faster than Safari in all but the try/catch tests (Going by the numbers he’s published)

Comment by Graham — October 12, 2007

“They didn’t test Opera, because he’s never seen anyone using it”
that’s just lame.I believe they WANTED Safari to be on the 1st place.
I use opera as my second browser, and my order of preference is FF,Opera,IE7, Safari…safari is on the last place because the windows version I’m using crashes very often.
Back to the topic, no serious benchmark should avoid or ignore Opera.

Comment by Michael — October 12, 2007

I have to say, Safari being in first place would not be what I would WANT. I have done the testing on Opera and it does perform extremely well on all tests and I will be updating the tests numbers at some point. IE 6 needs to be included as well as because many Enterprises still use it as the browser of “choice.”

Comment by Robert Buffone — October 12, 2007

Never seen anyone using Opera? Last I checked, Opera and Safari have a similar market share, they just don’t have Apple zealots pimping it.

I agree with Michael’s order of preference on my Windows machine, but on my Mac, Firefox and Safari are much closer because Firefox Mac is slooooow.

Comment by Andy Kant — October 12, 2007

“Clearly accessing properties directly is the best approach. Leave getters and setters to Java and C#, where the compiler will handle the optimization.”

Yeah, and unroll all your loops and don’t use classes because of the memory overhead.

This is such an old and stupid argument. For all but a few fringe cases it’s irrelevant which method is fastest. What is relevant is which method is most appropriate for the situation. Always using direct property access makes for weird bugs and maintainability nightmares.

Shame on Ajaxian for spreading this nonsense.

Comment by Theo — October 12, 2007

I should add, before some know-it-all does, that it is relevant to research performance. It’s good to know how a language works for those cases when you actually have to optimize. However, broad generalizations like the last sentence is what I find stupid and counter-productive.

Comment by Theo — October 12, 2007

Theo – Looking at the concerns of from the Ajaxian survey

1.) Cross-browser rendering 60.4%
2.) Runtime performance 48.7%

Runtime performance is a huge problem for people as they try to do more and more with JavaScript and Ajax. I can send you a long list of emails from people looking to work through their issues with performance.

A lot of times performance optimization doesn’t result in the prettiest or most optimal approach, but in the end what the end-user cares about is that the application is usable. Simple things can mean the difference between an application that runs fast an one that runs slow. Why is this?

Two reason:

1.) When exposing functionality to a developer, you know how you would like them to use it but you don’t know how they will. Providing a method like getCount() { return count; } may be the best approach but when that method is called thousands of times at a cost of 25%; then in the end it wasn’t the right approach.
2.) Developers cut and paste most of their code. A developer looks at piece of code that is using a getter and / or “in” operator and thinks to themselves, “hey, looks like a good idea” and uses it throughout their application whether or not that the first application of the code was “best practices”. Now everywhere they are looping through an array it cost them 500%.

I have been coding for 15 years and when I first got started I had a mentor that would make me re-write every for loop that contained a “non-primitive” as a length or where I didn’t define a variable to handle multiple object indirections a->b->c[0];. Why because the simplest things matter not just for usability but also for optimization.

“Every line counts” Look at some of the really good JS libraries out their, they apply a standard coding practice to make their code as optimized as possible, both in terms of the number of characters as well as speed. Not putting {} around single statement if, for, while loops may not make for the most readable code but it does make for the smallest code possible.

JavaScript has moved beyond, “Lets validate my email address” into a full fledged language people depend on JS to deliver applications that require 100,000+ lines of code. In these applications making sure to apply “old school” discipline and understanding of basic concepts with the new way to be successful it a necessity.

Comment by Robert Buffone — October 12, 2007

@Opera Users – I update the blog entry with Opera statistics.

Comment by Robert Buffone — October 12, 2007

who cares about Opera, really (except for a few geeks)? Come on guys, live in reality.

However, if you look at mobile browser, Opera might be interesting. on the desktop, sorry, guys, opera doesn’t exist.

Comment by Mark Arrington — October 12, 2007

I was going to complain about how the test results didn’t have Opera in them, but was pleasantly surprised about its inclusion in the reports now. They tell what most other tests before this have told: Opera is the fastest.

And then some troll food…

A lot of people use Opera, and their browser has been the first to use many now popular features, such as tabs. Also, it’s pretty funny how they still bother to develop it, knowing that no one uses it. Mmm yeah. Oh, and it’s not for just geeks either – I know a lot of computer illiterate people who love Opera.

Comment by Jani — October 12, 2007

If you had benchmarked Opera here it would have gone in CIRCLES around Safari while still getting a score fifty times better than Safari… ;)

Comment by Thomas Hansen — October 13, 2007

1.) At around 10,000 when popping elements off an array Safari become extremely slow. This wasn’t the case in other browsers but this area needs some further examination.

This is because Safari has small stack. 10x smaller than the other browsers, check out:

Comment by Chris — October 13, 2007

BTW FF3 is faster than Safari but not as fast as Opera.

Comment by Chris — October 13, 2007

So Opera is the fastest ha? Fastest rendering engine, fastest javascript engine. It doesn’t come as a surprise. Opera is the most innovating browser on the planet. IE is always 3 years behind and FF just one. Sure they don’t have the plugin capability (and neither the holes) of firefox but tabbed browsing, integrated download manager, password manager, keyboard navigation where invented by Opera. And we as web developers should promote it better. Wouldn’t our life be easier if IE would be at 8% market share?

Comment by Adrian — October 15, 2007

This is very interesting, try test:
t = ”;for(i=0;i=0;i–) doSomething(t[i]);

Comment by Mrrau — October 15, 2007

…. great, my previous JS code was deleted … so, forget it.

Comment by Mrrau — October 15, 2007

Leave a comment

You must be logged in to post a comment.