On 6 Mar 2014, at 11:29, David Rudel <fwqhgads@gmail.com> wrote:

I have a question that (I think) boils down to a question about TinyTree.

In an effort to keep this concise, I'll just come out and ask the question this way: Let's say that the context node may have at most one child with the name "c", but it can have any number of other children (elements with names other than "c").  Should the time required to retrieve the element <c> (if there is one), be affected by the number of other children that come before <c>?

In my testing, it seems like the processor knows enough about the names of the various children that it only "sees" the appropriate ones when doing an axis step. So, for example, the time required to execute something like "boolean(c)" or "<value-of select="c[1]/@brand"/> should not be influenced by the presence of non-c children.

Is this accurate? Are there limits to this general rule that one can assume (for purposes of performance optimization) that only nodes with the appropriate names are being inspected at a particular point in a path expression?

No, Saxon does a linear search so the time taken to find the c element is proportional to the number of preceding siblings. But it's a very fast linear search with an inner loop of only a few instructions, so you'll need a tree with a very large fan-out to measure the effect.

Michael Kay