Last night, I got into a discussion about XSLT processor performance. I thought that libxslt was the fastest freely avaliable XSLT processor, but I thought I should look for some proof. Searching for benchmarks, I found some benchmarks from 2001 which showed several of the java processors outperforming libxslt, but they were using libxslt 0.5, which was a rather early version of the library. Fortunately the benchmark was freely available, so I decided to download it and check modern processors.

XSLT benchmarks

Last night, I got into a discussion about XSLT processor performance. I thought that libxslt was the fastest freely avaliable XSLT processor, but I thought I should look for some proof. Searching for benchmarks, I found some benchmarks from 2001 which showed several of the java processors outperforming libxslt, but they were using libxslt 0.5, which was a rather early version of the library. Fortunately the benchmark was freely available, so I decided to download it and check modern processors.

The processors I have managed to check are,

Library versions
Library Tested version Previously tested version
libxslt 1.1.15 0.5.0
xalan-java 2.6.0 2.0.0
XT 2005-08-29 1999-11-05
Saxon 6.5.4 6.2.1

There are several implementations that I couldn't test. Sablotron hang on the second test, so couldn't complete the benchmark. The Xalan C processor has changed it's API significantly since the benchmark was written and couldn't be made to compile. The Oracle processor was unavailable at the time I tried to download it and the license wouldn't allow me to publish the results anyway. The Microsoft processor would have been interesting to compare, but I doubt it would run as expected under Wine. It also appears that the Sun processor has been donated to Xalan and is no longer available.

The benchmark itself is a set of 40 xslt stylesheets designed to test various areas of the specification for conformance and performance. These are descripted in table n.

It is worth noting that Xalan, Saxon and XT benchmarks include time to parse the XML documents, either because the API doesn't allow you to pre-parse the document, or the benchmark driver for that processor failed to take this into account. The only library tested that does pre-parse the xml is libxslt. In practice, the XML parsing is fairly insignificnt in the total processing times.

Test Component

Benchmark details
Benchmark Description
alphabetize This test takes a 100 row table and sorts them alphabetically.
attsets This test takes a small input document and copies nodes based on attribute sets.
avts Tests attribute-value template expansion.
axis Tests XPath selection along the different axes.
backwards Reverses order of elements in input document.
bottles Generates "99 bottles of beer on the wall" song.
breadth Performs a search for a unique element in a large tree.
brutal Executes many functions, sorts, etc.
chart Generates an HTML chart of some sales data.
creation Tests xsl:element and xsl:attribute.
current Tests complex XPath node selection.
dbonerow Selects a single row from a very large table.
dbtail Prints a table by traversing the following-sibling axis.
decoy Same template as patterns, with some decoy templates thrown in.
depth Performs a search for a unique element in a large tree.
encrypt Performs a Rot-13 operation on all element names and text nodes
functions Tests a variety of number and string functions.
game Produces a HTML table of the data.
html Literal result element as stylesheet example from XSLT spec.
identity The identity transform.
inventory Produces a HTML table of the data.
metric Converts metric units to English units.
number Tests format-number() function.
oddtemplate Tests a variety of complex match patterns.
patterns Stylesheet contains extremely simple templates with tough patterns.
prettyprint Formats the input input legal HTML.
priority Pops the first element off a priority Queue and returns the queue.
products Produces an HTML table from the data.
queens Solves the "8 Queens" problem. (Stylesheet by Oren Ben-Kiki, used with permission.)
reverser Stylesheet copies input with text-node strings reversed.
stringsort Performs a sort based on string keys.
summarize Reports information about an XSL stylesheet.
total Reports on sales data.
tower Solves the Towers of Hanoi problem.
trend Computes trends in the input data.
union Performs complex pattern matching.
xpath Performs complex pattern matching.
xslbench1, xslbench2, xslbench3 These three tests come from Kevin Jones' XSLBench test suite, used with permission.

Results

Looking at the overall graphs, it is clear that libxslt is by far the fastest performing processor, being 50% faster than XT and nearly 5 times faster than Xalan. In the 2001 benchmarking, libxslt was just slightly slower than saxon, but in comparison, today it is 2.3 times quicker.

In the previous test it was clear that programing language didn't have much bearing on the processing speed, but now the C library is clearly faster than any of the Java processors. It is hard to tell if this is a limitation in java or if it is down to a very well tuned libxslt. It would have been nice to test Sablot and xalan-c, but without fixing the problems above we won't know for sure.

http://www.tfi-technology.com/xml/xslbench.html http://www.xml.com/pub/a/2001/03/28/xsltmark/index.html http://www.datapower.com/xmldev/xsltmark.html

Further Reading