[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: rephrased: passing parameters to generic templates
> amazingly this is true > > I've just ran a comparison on a set of 20,000 nodes and the results > were near identical.... > > I will now freely use ancestor with a clear conscience! > > So how can getting the parent of each node in the ancestry be as fast > as essentially not getting the parent of each node (tunnelled > parameters cant cost anywhere near as much)? Is there trickery > involved? No trickery, just code. I can only suggest you study the relevant paths in the Saxon source code. When the tree is a TinyTree, Saxon represents nodes using a transient TinyNodeImpl object: usually, depending on the path by which the node was reached, this will contain a reference to the TinyNodeImpl object representing the node's parent in the tree. So following the ancestor axis just involves one pointer dereference for each step along the axis, plus a test to see whether the node satisfies the required Nodetest: for a node test of the form ancestor::A, this is essentially two integer comparisons, one to check that you've found an element node and one to check the name. Tunnel parameters involve a small overhead on every template call. The set of tunnel parameters passed to (or through) a template is held in a hash table (indexed by parameter name represented as an integer code) which is referenced from the stack frame for the template; this hash table is copied on each call to make sure that changes don't affect the caller. There's scope for optimization here (for example, one could avoid copying the hash table when this isn't necessary, or one could do a long search down the stack when accessing a tunnel parameter so that there is zero work in passing them along). Currently the only case that's optimized is the case where there are no tunnel parameters at all. Part of the lesson here is simply that features that are used more frequently tend, over time, to be more heavily optimized. Tunnel parameters have not yet featured in any benchmarks... Michael Kay http://www.saxonica.com/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|