Re: Fwd: [xsl] curly braces

Subject: Re: Fwd: [xsl] curly braces
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Thu, 20 Sep 2012 10:11:12 +0100
You need to explain how these measurements were taken: was the stylesheet compiled inside the loop or outside it? Was the same Transformer used repeatedly, or a new one created each time? There are scenarios where building an index on the stylesheet document would be better because the same index is reused repeatedly, whereas with a temporary tree a new index will be built each time. If you have a large lookup document then I would recommend making it a separate free-standing document, and building it outside the transformation (not using doc(), supplying it as a stylesheet parameter); if you then use the same compiled stylesheet repeatedly, both the lookup document and its index will be reused for each transformation. If you're only using the stylesheet once, however, putting the data inline in a global variable will be a little faster.

Michael Kay
Saxonica


On 20/09/2012 02:12, Ihe Onwuka wrote:
On Thu, Sep 20, 2012 at 12:11 AM, Michael Kay <mike@xxxxxxxxxxxx> wrote:

The idea of reading the source document using document('') is a hack used in
XSLT 1.0 to get around the restrictions on using result tree fragments. It
is never needed in XSLT 2.0: use the global variable directly. (It's also a
very inefficient hack, because the stylesheet has to be parsed twice.)

My benchmarks don't bear that out (To be fair the stylesheet is
compact but still......).
  Higher average execution time when not using doc('') but with a
smaller range and variance (which I haven't calculated but stands to
reason because of the outliers).

Benchmark data

Version with document('')

Ignoring first 2 times
Total Time (last 998 runs): 2 minutes 9 seconds
Average Time (last 998 runs): 129 ms

Only 4 responses above 1 second.
Slowest response 2.75 seconds


Version without document('')


Ignoring first 2 times
Total Time (last 998 runs): 2 minutes 23 seconds
Average Time (last 998 runs): 143 ms

All responses below 1 second
Slowest response 657ms

Current Thread