xsl-list
[Top] [All Lists]

RE: [xsl] Problems calculating the running time of an xsl script

2009-12-10 08:22:05

On each XSL files I'm setting a global variable to store the 
current date time.

<xsl:variable name="startExecutionTime" as="xs:dateTime">
    <xsl:value-of select="current-dateTime()"/>
  </xsl:variable>

Why 3 lines of code where one would do?

<xsl:variable name="startExecutionTime" as="xs:dateTime"
select="current-dateTime()"/>


The template appends start and current time and calculates 
duration minutes although unlikely and seconds

All calls on current-dateTime() within a single transformation are required
to return the same result. This is because order of execution in XSLT is
undefined - it's meaningless to talk of which expressions are evaluated "at
the start" or "at the end" of the transformation. For example, a global
variable might be evaluated at the start, or it might be evaluated on first
use - or even on each use if the processor so decides.

Is there a way to calculate the running time of an xsl script 
within the script?


You can call extension functions, recognizing that the result of calling
"impure" extension functions is not 100% predictable.

But for most purposes, I'd suggest that measuring it externally (from the
calling application) makes more sense.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--