[XML-SIG] 4XSLT focus on docbook stylesheets (and fruit thereof)

Mike Brown mike@skew.org
Mon, 15 Jul 2002 01:07:07 -0600 (MDT)


Thomas B. Passin wrote:
> Outstanding!  Any ideas how that compares with the big guns (Xalan, msxml,
> saxon)?

I just ran some tests against one of those guns.

The contenders:

4xslt 0.12.0a3(*), incorporating expat-1.95.2, under Python 2.2.1
vs
Saxon 6.5.2, with its modified Aelfred parser, running under JDK 1.1.8.

(*) what will become alpha 3, rather

The platform:

Intel PIII-933, 256 MB RAM, FreeBSD 4.6-STABLE.

The test:

Transforming a 450-line, 25K Simplified DocBook article to HTML,
using DocBook XSL 1.50.

=============================================================================

Battle #1: The simplest test: command-line, with all the overhead of
the JVM and Python interpreter starting up to throw off the results.


% /usr/bin/time -h 4xslt QuickStart.xml docbook-xsl-1.50.0/html/docbook.xsl > out.html 
        13.63s real             12.95s user             0.39s sys

% /usr/bin/time -h java com.icl.saxon.StyleSheet QuickStart.xml docbook-xsl-1.50.0/html/docbook.xsl > out2.html
        22.80s real             21.61s user             0.22s sys



Outcome: 4xslt finishes about 67% faster than Saxon


=============================================================================

Battle #2: A proper test: timing the stylesheet preparation and
transformation separately, from code.


% cat 4x.py
import time
from Ft.Xml.Xslt import Processor
from Ft.Xml import InputSource
from Ft.Lib import Uri

processor = Processor.Processor()
source = InputSource.DefaultFactory.fromUri(Uri.OsPathToUri('/home/mike/xml/test/QuickStart.xml'))         
transform = InputSource.DefaultFactory.fromUri(Uri.OsPathToUri('/home/mike/xml/test/docbook-xsl-1.50.0/html/docbook.xsl'))     

t0 = time.time()
processor.appendStylesheet(transform)
t1 = time.time()
print "stylesheet preparation: %ss" % str(t1 - t0)

t0 = time.time()
result = processor.run(source)
t1 = time.time()
print "transformation: %ss" % str(t1 - t0)



% python 4x.py
stylesheet preparation: 6.11614501476s
transformation: 6.85079503059s



% cat XsltTest.java
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;

public class XsltTest {

    public static void main(String argv[])
        throws TransformerException, TransformerConfigurationException {

        long t0,t1;
        String sourceID = argv[0];
        String xslID = argv[1];

        t0 = System.currentTimeMillis();
        TransformerFactory tfactory = TransformerFactory.newInstance();
        Transformer transformer = tfactory.newTransformer(new StreamSource(xslID));
        t1 = System.currentTimeMillis();
        System.out.println("stylesheet preparation: " + ((t1 - t0)/1000.000) + "s");

        t0 = System.currentTimeMillis();
        BufferedOutputStream output = new BufferedOutputStream(new ByteArrayOutputStream());
        transformer.transform(new StreamSource(sourceID),
                              new StreamResult(output));
        t1 = System.currentTimeMillis();
        System.out.println("transformation: " + ((t1 - t0)/1000.000) + "s");
    }

}



% javac XsltTest.java
% java XsltTest QuickStart.xml docbook-xsl-1.50.0/html/docbook.xsl
stylesheet preparation: 11.307s
transformation: 10.995s


Outcome: 4xslt about 85% faster than Saxon at stylesheet preparation,
         and 4xslt about 60% faster than Saxon at transformation.

=============================================================================

If anyone wants the QuickStart.xml that I was using, or wants to demand a
rematch with Saxon 7 or DocBook XSL 1.52.2 or whatever, or offer
constructive criticism to make these tests better, please drop me a line,
or run better tests yourself :)

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/