Thursday, September 16, 2010

More Performance Comparisons

I have been looking into doing more audio work in JavaScript, now that both Mozilla and Google have draft specifications for JavaScript audio APIs.

I had been of the opinion that JS was way to slow to bother with. For example, if you run the ActionScript mixing test (documented in the post below) on the major browsers using bog-standard Array structures you get numbers over an order of magnitude slower than the optimized ActionScript counterpart.

The new WebGL typed arrays in Mozilla are MUCH FASTER, and probably good enough to start doing interesting work with. But who knows how long it will take for them to be widely adopted? The floating point arrays in the Firefox 4 Beta are about 3x as fast as Vectors in ActionScript under Flash Player 10.1, but still slower than Alchemy-compiled code.

These are my numbers for mixing 50x32k sample buffers on each platform.

Chrome 6 JavaScript Arrays: 467ms
Safari 5 JavaScript Arrays: 369ms
Firefox 4 JavaScript Arrays: 136ms
Firefox 4 New WebGL Float32Arrays: 22ms
Actionscript Alchemy C Arrays: 10ms

Again this type of performance comparison is ridiculously simplistic, but you need a ballpark understanding of some basic metrics to get anywhere with audio code.