On 02/02/2013 22:56, Michael Kay wrote:


I'll have a play with the example and see if I can add any insights.


First experiment: see what the impact of bytecode generation is. Answer: it brings the runtime down from 19.8s to 17.2, perhaps 15%. That's not untypical, but sometimes with stylesheets dominated by computation the effect is much greater; it suggests the time is dominated by something where bytecode generation has relatively little impact.

Next experiment: switch on Java profiling. This shows the performance dominated by two things: ArrayIterator processing, which is presumably the repeated iteration over the elements in the data file, and string-to-double conversion.

Next experiment: run with -TP:profile.html. Unfortunately this causes the transformation to fail with a stack overflow. I think that tail-recursion is being suppressed because it makes it impossible to get a useful execution profile.

Another way of saving the repeated string-to-double conversion cost might be to use a memo function: extract the double value of each attribute of the data file using a function declared with saxon:memo-function="yes".

Using tunnel parameters isn't going to help performance. The cost of passing the parameter is negligible; it's the cost of repetitive processing of the data that's the concern. Try passing 5 parameters, each a sequence of xs:double values, rather than a sequence of elements containing these five numbers as attributes.

Michael Kay
Saxonica