Re: [xsl] How to output the start execution time and the end execution time?

Subject: Re: [xsl] How to output the start execution time and the end execution time?
From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 6 Sep 2014 16:22:23 -0000
The concept of "Execution Time" is typically not defined in a functional
programming language.

In XSLT we could get the time from an external resource and this is rather
simple. Just use something like this:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="/">
   <xsl:variable name="vStart" select=
   "document('
http://developer.yahooapis.com/TimeService/V1/getTime?appid=YahooDemo&amp;format=ms&amp;x=y
')
       /*/*:Timestamp/node()
   "/>

   <xsl:apply-templates/>
   <xsl:variable name="vEnd" select=
   "document('
http://developer.yahooapis.com/TimeService/V1/getTime?appid=YahooDemo&amp;format=ms&amp;x=z
')
       /*/*:Timestamp/node()
   "/>
   ============================
   Start time: <xsl:sequence select="$vStart"/>
   End time: <xsl:sequence select="$vEnd"/>

   Duration in ms: <xsl:sequence select="$vEnd -$vStart"/>
  </xsl:template>
</xsl:stylesheet>

When this transformation is applied on the following source XML document:

<person xmlns="x:y">
 <name>John</name>
 <age>23</age>
 <profession>carpenter</profession>
 <country>USA</country>
</person>

it processes it (in this case a simple identity transform) and then prints
the start and end time in milliseconds and what could be considered the
duration of the transformation:

<person xmlns="x:y">
   <name>John</name>
   <age>23</age>
   <profession>carpenter</profession>
   <country>USA</country>
</person>
   ============================
   Start time: 1410020202281
   End time: 1410020202343

   Duration in ms: 62

Remember, that what is really problematic, is to know what would be the
"last executed code", so that we should place the second call to the
time-service there.

Cheers,
Dimitre




On Sat, Sep 6, 2014 at 2:46 AM, Costello, Roger L. costello@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Hi Folks,
>
> I would like to:
>
> 1. Output the time that my XSLT program starts processing
> 2. Do the processing
> 3. Output the time that my XSLT program finishes processing
>
> This doesn't work:
>
>     <xsl:template match="/">
>         <xsl:value-of select="current-time()" />
>         ... do the processing ...
>         <xsl:value-of select="current-time()" />
>     </xsl:template>
>
> What is the correct way to accomplish this?
>
> /Roger
> 
>



-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they write
all patents, too? :)
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.

Current Thread