Comparing Browser JavaScript Performance
Thwomp writes "Over at Coding Horror Jeff Atwood has an interesting writeup on JavaScript performance in the big four browsers. He used WebKit's newly announced SunSpider to produce the results. If a probable anomaly in the IE7 results is overlooked, Firefox 2 is the slowest of the bunch. Atwood has also benchmarked the latest Firefox Beta, and its performance seems to be improved significantly."
Take note of the tests for the latest Firefox beta though, notice that he's using a different system with .2Ghz more and he's on a 64 bit system versus a 32 bit. Although it's not a huge leap, it IS a difference. Different system different benchmark.
> if a probable anomaly in the IE7 results is overlooked
;)
Like what? It didn't crash the system or it actually launched
Bark less. Wag more.
With NoScript, Firefox's performance easily soars above the rest?
Looks like they are finally getting their javascript act together. After being a sore point for so many years, a working javascript in Opera will be welcome.
What an absolutely horrible speed test.
First off IE6 is not tested, while it is still the most used browser. Also Opera 9.5 is not ready, it has so many bugs it just isn't funny anymore. Many sites break that worked fine in Opera 9.2.
But let's get to the good stuff. Yes in pure JavaScript like this, IE might be faster than Firefox. But in real world situations it clearly isn't. There is no test done on layout manipulation (and such) using JavaScript. Internet Explorer is notoriously horrible at this, especially if you use it combination with PNG's with alphachannel or complex CSS. Not to mention if you have to use JavaScript hacks because of IE6's lack of CSS support for the simplest things.
Funny is also how almost all JavaScript library speed tests I've seen put Internet Explorer far behind the others.
In 'real world' JavaScript performance Opera and Safari would be the winners, where I'd choose Safari as absolute winner, as Opera gains a lot of redrawing speed by cutting corners it should not cut which often result in display corruption (ie, the type that goes away when you force a redraw by minimizing and then maximizing the window again, or moving another window over Opera and then away again). Quite a bit behind in speed after Safari and Opera would be Firefox, followed even further back by Internet Explorer.
As a developer I still prefer Firefox for development though. Webkit is awesome, but the Safari GUI just plain sucks. Opera... hmm, I like it on my mobile devices, but it's just too weird for the desktop (what, textarea's don't even support scrolltop? wth!)
here
AMD Athlon 64 3200+, 1GB, Ubuntu 7.04, using FF for 4 hours, listening to last.fm.
CC.
TaijiQuan (Huang, 5 loosenings)
Because of the incompatibilities and different bugs between browser JavaScript implementations for God's sake let's not have a world where client-side JavaScript is so fast we use it for everything. Development time will increase one more fold for each browser you want to support, and sometimes additionally for each minor version It will be hell on earth I predict.
My basic rule of thumb has also been that client scripting should enhance and application but not be required for the application. In other words with JavaScript disabled the application might act rudimentary but will still produce results.
I'd like to see a similar test for OSX, maybe replacing IE with Camino (since I don't think IE will be made for OS X again?). Links, anyone?
It takes time to change the setting in NoScript to allow JavaScript on the page in the first place.
I wouldn't give up that additional slowness for a 10,000% performance increase.
Aside from jscript lacklustre string handling, I've still never found it faster than spidermonkey. In some base64 tests I did, Opera fared really badly using an algorithm I found on their site -- while leading the pack with one I wrote myself. What I discovered was that given the right set of tests, any implementation can look favorable.
The unoptimized spidermonkey cli shell firmly trounced kjs last year when I did my testing, more likely what's being measured by these benchmarks is DOM access.
Why don't people just stop making ridiculously complicated pages? Have you seen the yahoo hompage? Aol's is even worse. And Ebay's is a ridiculous nightmare. I don't who thought that looked good or thought people will look at or read that much but they should be fired. No browsers in the world could render those pages in under a second the way they're supposed to look. Plus remember that like 99% of page load slowness is from ad servers failing to load the ads fast enough
Google's Super Secret Search Algorithm: SELECT @search_results FROM internet WHERE @search_results = 'good'
I tried the same benchmark with my browser and it seems to beat them all, only 17 ms to pass the test !!!
~$ time lynx -dump http://webkit.org/perf/sunspider-0.9/sunspider-driver.html
SunSpider JavaScript Benchmark (In Progress...)
real 0m0.017s
user 0m0.001s
sys 0m0.004s
~$
Everything I write is lies, read between the lines.
Bizarrely, Firefox for Windows running through wine runs faster than native Firefox. The wine installation doesn't have any add-ons though, so that might be the difference. Wine version is 0.9.51 and windows firefox version is 2.0.0.9, same machine as my post above.
Wine results. Native results.
"If a probable anomaly in the IE7 results is overlooked" you mean like how IE7 goes backwards in Java implementation vs IE 6.
"Slashdot, where telling the truth is overrated but lying is insightful."
Good! Now that somebody has done a benchmark and it's been featured here, I expect some serious work will be done on JavaScript. I think performance will increase enormously in at least the developer-friendly browsers.
Please correct me if I got my facts wrong.
I did a simple animation recently using javascript to move a couple of (DOM-)elements around the page it was jerky and ugly on IE (both 6 & 7), better in Konqueror and perfectly smooth in Firefox.
I suppose that's not a measure of performance as much as a measure of quality, but a few percent less cpu usage doesn't matter one bit if the result is ugly.
FireFox was supposed to be getting a JIT compiler for JavaScript. It's the one from the Flash player, where it runs ActionScript. That's apparently now expected in 2008. Then we'll see some real improvement.
I have to confess that my favored browser, Konqueror, needs a swift kick in the ass when it comes to Javascript support. Too often I have to fire up Firefox in order to browse pages that have some measure of interaction, e.g. uploading images of things I'd like to sell on eBay. It's a shame, because otherwise, Konqueror is a wonderful, snappy browser. Here's hoping its devs whip it into shape sooner rather than later.
If no one makes excuses for Firefox's Javascript performance, especially if IE is faster than it... because I hate how IE handles DOM. Compared to the other browsers, which handle DOM okay, Firefox could do better however.
"Thanks for all the money you paid to us. We've used it to buy off ISO among other things" -Microsoft
I use a 3rd party build of Firefox, on my system I saw a ~25% speed increase in the test going from 12s on the standard firefox build to 9s on the third party build
You know, it's cute to refer to "the big four" browsers, but you could've at least listed what you think those are - we are not mind readers.
Had it been "the big one and the one that just edged into relevance", then most people would know what you meant.
sic transit gloria mundi
Okay, maybe not, but this is my numbers:
WinXP Firefox 2.0.0.11: 18.8s
WinXP Internet Explorer 7.0.5730.11: 33.1s (same issue with the strings performance)
Ubuntu Firefox 2.0.0.6 (yeah, well): 15.3s
I only have opera running on my WinMobile Dell Axim v51x PDA and it's currently running, it seems to be 30-40 times slower than the desktop, so I'll not be waiting before I post...
TC - My Photos..
Firefox, for me, is really stable unless Flash is involved. Add Flash to the mix, and it goes down faster than a two dollar whore on a Friday night. By the way, so does Opera, but not quite as often. Close though. Just try watching 4-5 videos on YouTube.
I think Flash is the biggest DoS in the history of the web and Adobe really needs to take a good look at it. With all of these Flash ads and Flash-based video players, it really is a critical issue. Using adblock is an absolute must in my book, just to keep the browser running. My bet is some sort of resource leakage, since it happens over time -- like when watching several YouTube videos. It doesn't crash on the first or second one, but you're courting disaster on the third and above.
By the way, is there any way for FF to handle plugin crashes gracefully, i.e. *without* bringing down the browser with it? Maybe running it in a separate process somehow and just putting up a "broken image" sort of placeholder?
If you run the MooTools Slickspeed tests in different browsers, you find something interesting:
jQuery also claims to be the most accurate, though who knows for sure.
$nice = $webHosting + $domainNames + $sslCerts
AFAIK, Tamarin was since the beginning scheduled for Gecko 2 (i.e., Firefox 4). So, don't worry, it's not like it didn't make for Fx3, it wasn't supposed to be on this week's beta at all.
Posted in the comments to TFA:
There was an article about IE's string performance in the Jscript team blog on MSDN a while back : http://blogs.msdn.com/jscript/archive/2007/10/17/performance-issues-with-string-concatenation-in-jscript.aspx
Aaargh! on December 20, 2007 11:34 AM
Seems to me that the more important ones are all for firefox. FF beats IE on access, control flow, crypto and strings. IE beats FF on 3D, bitops, date and regexp. They are about even on math.
Now bitops could be important for a browser, but I would not see too many pages doing things with 3D. Date and regexp are important, but they are hardly things you do in a loop on a regular basis. Access, control flow, crypto and strings seem more important to me.
Just adding up the benchmark results was pretty weird imho. Just putting them in 9 separate screens would be better, especially if the author had the decency to at least look up the contents of the tests. Ah well, presentation over content I suppose.
Once you need a benchmark to prove something is faster than something else, then it doesn't really matter which one you uses.
Copyright infringement is "piracy" in the same way DRM is "consumer rape"
It seems strange that add-ons for Firefox should slow down Javascript execution times. I did a test to confirm it, but it's apparently the case. My guess is that it's because add-ons which execute as pages are loaded mess with the benchmark. My FF was 2x slower with add-ons.
const int one = 65536; (Silvermoon, Texture.cs)
SJW, n: "Someone I don't like, and by the way I'm a fuckwit" - AC
The actual problem is the way JScript does string concatenation.
:)
When you concatenate 2 strings in JScript, it determines the size of the buffer needed, allocates the buffer, does the concatenation, and returns the result to the caller.
Which works fine, until you start putting some load on those old tires...
x = 'some';
y = 'string';
z = 'here';
testString = x + " " + y + " " + z;
(Ignore that nobody would actually write code JUST LIKE THAT, they would just add a trailing or leading space to the x, y & z strings. But concatenating a result with some white space is not abnormal.)
Now, just think about what this is actually doing under the hood..
1. determine len of x (4) plus len of " " (1) = 5
2. Allocate new buffer(5)
3. Concatenate, assign result to temp
4. determine len of temp (5) plus len of y (6) = 11
5. Allocate new buffer(11)
6. Concatenate, assign results to new temp, destroy old temp
7. determine len of temp (11) plus len of " " (1) = 12
6. Allocate new buffer(12)
8. Concatenate, assign results to new temp, destroy old temp
9. determine len of temp (12) plus len of z (4) = 16
10. Allocate new buffer (16)
11. Concatenate, assign results to testString
So, to concatenate relatively little string data, 3 temporary buffers were needed and 4 separate allocations were done.
It works fine, right up to the point where it doesn't
You can't handle the truth.
For compressing roughly a 100K js, IE7 is far faster than Firefox. I've seen firefox take over an hour to compress js with interruptions that "this script is running too slow", while IE takes only a few minutes. Opera corrupts large scripts, so it's useless in this context. I haven't tested Safari for compressing javascript.
However, for real 3D, IE7 is really really really slow. Firefox is OK, Safari on windows is the fastest. http://www.abrahamjoffe.com.au/ben/canvascape/textures.htm
> Had it been "the big one and the one that just edged into relevance", then most people would know what you meant.
IE6 & IE7?
I've found unable to test Opera 9.5b on WebKit's SunRise test. Thus I've tested using this one: http://www.jorendorff.com/articles/javascript/speed-test.html and it appears that standard Safari from Leopard (version 3.0.4, build 5523.10.6) in some places same as Opera 9.50b, in some places bit faster and in some places as twice as faster than Opera. Also, Opera fails lots of tests with traceback errors.
Check it out yourself.
In general, it is safe and legal to kill your children. -- POSIX Programmer's Guide
I did the test on a dual-boot Intel Core 2 Duo 2.0 GHz with 2 GB RAM Comparing Vista and IE 7 with Ubuntu 7.10 and FireFox 2. Vista took 17461.6ms and Ubuntu took 12532.4ms for a 15% improvement.
Here are the links to the full reports:
Windows Results and Ubuntu Results