YUI Now on TaskSpeed Benchmark

This last two weeks involved some work by a few YUI community members, and the YUI team to bring YUI to the TaskSpeed JavaScript benchmark. TaskSpeed is based off of SlickSpeed, and both are designed to test the CSS Selector engines used by popular JavaScript libraries, but TaskSpeed adds basic DOM manipulation tasks in an attempt to determine the speed of that JavaScript Framework for common operations.

I was asked to lend a hand with the TaskSpeed tests for YUI, and while I did contribute some code, the bulk of the work was done by Eric Ferraiuolo, with some performance cleanups offered by Luke Smith of Yahoo!. The YUI 2.7.0 version is already up on the TaskSpeed site, and we’re waiting on some fixes to land in the YUI 3 branch on GitHub, namely a few weaknesses surrounding YUI 3’s CSS Selectors that need to be addressed. The small amount of work I did was around the YUI 3 tests.

What I found to be greatly impressive was how well YUI 2 holds up compared to, say, JQuery. YUI has a reputation among a lot of web developers for being really bloated. At least with YUI 2, this seems to have little basis. The YUI-270.js filed used in TaskSpeed weighs in at only 44K, easily the most compact of the frameworks (JQuery 1.3.2, comes in second at 56K). Not only that, but in several cases it significantly outperforms the other frameworks (to be fair, in a few tests, it’s beaten out by JQuery handily).

This is probably one of the most significant comparisons of Framework performance that I’ve seen, since it’s one of the only benchmarks I’m familiar with that specifically targets the Frameworks, and not the underlying browser engine. Due to this, it serves as a good benchmark for decided what kind of DOM operations are most important to your app, and what engine will likely do best under those circumstances. On the other hand, the tests are somewhat contrived as they usually involve a significant number of repititions on a test, which is somewhat less realistic, but still interesting.

Ultimately, should you choose your JavaScript library based on this test? Probably not. All of the libraries featured in TaskSpeed perform fast enough that under normal circumstances you’d probably not notice major differences in application performance. More important, is if the engine enables you to write what you consider to be ‘good’ code. Plus, these tests aren’t always consistent. I ran TaskSpeed on my workstation on Windows Server 2008 in Workstation Mode on Firefox 3.0.8, and on an Ubuntu 8.10 VMWare VM on the same workstation on Firefox 3.0.3. The removeclass test for the qooxdoo 0.8.2 library took 20 ms in the VM, and 181 ms on my workstation. And yes, normally the workstation was 25-40% faster than the VM. I’m on an quad core machine which isn’t doing a whole hell of a lot, so all I can figure was that the browser got swapped away from for some reason at an inopportune time or something.

It will be interesting to see how YUI 3 fares as some of the bugs in the framework (which is still alpha) get worked out, and the speed improved. YUI 3 is definitely a syntactic improvement over YUI 2, but I hope that the YUI team, and the Community surrounding them (particularly now that code can be more easily contributed to via github), will work to make YUI 3 a faster and better product than YUI 2 is today. While I may be downplaying the significance of benchmarks in general, I do feel this is significant because it shows that YUI really does hold it’s own among other frameworks.