JavaScript Benchmarking - Part 3.1 | September 15th, 2005
With the open source release of Google�s GOOG-AJAXSLT JavaScript library I thought that it would be interesting to look at the performance in various browsers. It is of particular importance when building responsive AJaX applications on Opera, which does not support XSL-T at this time. Of course there is no reason for using this library in Firefox or Internet Explorer since they both have support for doing XSL-T transformations.
I made a simple XSL-T document that used various functions such as etc and had it generates some HTML output. I measured the time taken to perform the transform operation with varying numbers of rows in the output HTML. The result is short and sweet and can be seen below.
Luckily, it performs best on Opera which is the browser that does not natively support XSL-T. That being said, in the region of interest here the built-in transformation engines in IE, NS and FF can do the work in the 1ms range.
The question is can there be any optimization done to make the code run faster? Looking through the code I did notice that there are many loops that check values such as node.children.length on every iteration and similarly access node.children[i]. Also, there are many functions that use += to concatenate strings and we all know that building an array and calling stringArray.join('') can be very fast when dealing with large strings. Depending on the size of the transformation there could be performance gains there.
Tests were done on a 2GHz Celeron running Win2K server using IE6, NS8, FF1 and OP8.
April 9th, 2006 at 1:01 pm
[...] References [1] The AJAX Response: XML, HTML or JSON - Peter-Paul Koch, Dec 17, 2005 [2] Objectifying XML - E4X for Mozilla 1.1 - Kurt Cagle, June 13, 2005 [3] JavaScript Benchmarking - Part 3.1 - Dave Johnson, Sept 15, 2005 [...]