Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Performance of Java XPath engines

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <whoschek AT lbl.gov>
  • To: "Michael Kay" <mike AT saxonica.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Performance of Java XPath engines
  • Date: Wed, 19 Jan 2005 02:09:47 -0800

On Jan 19, 2005, at 1:39 AM, Michael Kay wrote:

Thanks very much for this: very useful data.

I'm not greatly surprised that Saxon is slower over DOM than over other data
models, but it's nice to have confirmation. I could speed it up, for example
by assuming DOM level 2 support, but I don't feel strongly motivated to do
so. If you excluded the time for compiling the XPath expression, and only
measured the execution time, the difference would be even greater.

(For many of these expressions, I suspect the cost is dominated by
compile-time costs. In fact, many of them will be be completely evaluated at
compile time.)

As an aside, XQueryUtil.xquery(Node n, String query) is not only convenient but also efficient as it automatically uses a compiled query the second time it sees it.


From my own point of view, I would love to see how these figures for Saxon
compare with running Saxon over its native (TinyTree) data model: I would
expect these figures to be considerably better, but I'd like to know how
much better. Apart from anything else, this would set a target for improving
the XOM wrapping layer.

Shirasu, if you'd like to do this, an easy way to test the Saxon TinyTree is by supplying a File or InputSource or a saxon NodeInfo as a query variable to Nux. It's not documented (and hence may change in the future without notice) but currently it works that way.

Example:

XQuery xquery = new XQuery(declare variable $foo as document-node() external; $foo/a/b/c", null);
Map vars = new HashMap(1);
vars.put("foo", new File("/tmp/test.xml"));
for (repeat many times) {
Nodes results = xquery.execute(null, null, vars).toNodes();
}

The problem here is that the file gets parsed anew on each run, which is probably not what one wants for meaningful performance comparisons. You'll probably want to avoid that via something clumsy like this:

StaticQueryContext context = new StaticQueryContext(new Configuration());
DocumentInfo doc = context.buildDocument(new InputSource("file:///tmp/test.xml"));
XQuery xquery = new XQuery(declare variable $foo as document-node() external; $foo/a/b/c", null, context, null);
Map vars = new HashMap(1);
vars.put("foo", doc);

for (repeat many times) {
boolean notEmpty = xquery.execute(null, null, vars).next();
}

the last line only retrieves the first result in order to focus (almost) exclusively on the performance of the tinytree.
Hope this helps.





Archive powered by MHonArc 2.6.24.

Top of Page