RE: [xsl] performance of variables in a xpath expression

Subject: RE: [xsl] performance of variables in a xpath expression
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 19 Mar 2003 23:48:44 -0000
> im curious about how much slower it is to use a
> variable in a xpath expression. 

The answers to performance questions always depend on which XSLT
processor you are using: without that information, the question is
meaningless.

Even with that information, one would need to see the two stylesheets
you are comparing; and as an implementor I would find out the answer by
measuring both and giving you the figures - which you could do just as
easily yourself.

There are some circumstances in which using variables can greatly help
performance, there are also some circumstances in which they might slow
things down. In theory, given a perfect optimizer, it probably wouldn't
make any difference either way; but optimizers are not perfect. Using a
variable will often be taken as a hint to the processor that you want to
use the value more than once: the chances are that if you put a value in
a variable, the processor is more likely to allocate memory to it rather
than computing the value repeatedly. Allocating the memory may or may
not be cheaper than recomputing the value.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread