[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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 18:30:14 -0000

Hi Wolfgang,

I duly noticed the challenges in my message, so we both agree on this.

This is why my immediate reaction war to send to Roger (offlist) this
suggestion:

"One simple way is to run the transformation using the standard (for
that XSLT processor) command-line utility. Just set your command
prompt to display the time. :)"


I think that Abel's proposal to use <xsl:next-match> is a good one and
coupled with accessing a time server would be useful.

Then the main problem, if the programmer wants to make many timings,
is to have as many different strings to put in the URL in order to
trick the XSLT processor in thinking these are different URLs.

One safe approach to do this is to use the result of the previous
timing, which we would pass as a parameter to <xsl:next-match>   :)

Cheers,
Dimitre

On Sat, Sep 6, 2014 at 10:09 AM, Wolfgang Laun wolfgang.laun@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> Dimitre,
>
> given that the call to an external timepiece delivers the wallclock time:
> how can one be sure that a call near the top of the  XSLT program is
> executed first, e.g., before accessing the main document? And how can one be
> sure that a call near the end of the program is the last thing the program
> does, e.g., even after writing/serializing everything and flushing all
> buffers?
>
> Not really knowing what one measures? Not being sure how the data influences
> the result?
>
> -W
>
>
>
> On 6 September 2014 18:31, Abel Braaksma (Exselt) abel@xxxxxxxxxx
> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>>
>> Hi Roger,
>>
>> Functions and constructs in XSLT and XPath are stable (barring a few
>> exceptions). Calling a function with the same argument twice will yield the
>> same result for both calls. The functions current-time(), current-dateTime()
>> and current-date() will therefor always return the same time (with a slight
>> caveat for static and dynamic evaluation phases, but let's not digress).
>>
>> The only way out here is extension functions, or a trick with XSLT 3.0
>> using streaming, because the xsl:stream instruction is deemed non-stable
>> (i.e., it will re-invoke the url at the href argument each time it is
>> called). Whether an extension function helps depends whether your processor
>> allows non-stable extension functions, but I believe most, if not all,
>> processors do.
>>
>> Here's a (workable) trick that works with all XSLT 3.0 processors, however
>> you might want to choose a local resource instead that returns the current
>> date-time, for performance reasons.
>>
>>
>> <xsl:mode streamable="yes" name="time" on-no-match="shallow-skip" >
>>
>> <!-- may need an actual argument to force re-evaluation -->
>> <xsl:function name="my:current-time">
>>   <xsl:stream href="http://time.is">
>>     <xsl:apply-templates mode="time" />
>>   </xsl:stream>
>> </xsl:function>
>>
>> <!-- match the element that contains the time -->
>> <xsl:template match="div[@id = 'twd']">
>>     <xsl:value-of select="." />
>> </xsl:template>
>>
>> <xsl:template match="/">
>>      <xsl:value-of select="my:current-time()" />
>>      ... do the processing ...
>>      <xsl:value-of select="my:current-time()" />
>>  </xsl:template>
>>
>>
>> Note: the page http://time.is currently does not deliver proper XML (and
>> on my search for a time server that did deliver proper XML or even proper
>> XHTML I did not find any). If you can convince your processor not to cache
>> the result of unparsed-text, you can use the following with the same server
>> as a workaround (ugly, but it shows the principle):
>>
>> <xsl:value-of select="replace(unparsed-text('http://time.is/'),
>> '.+twd&quot;&gt;([^&lt;]+).*', '$1', 'sm')" />
>>
>> Cheers,
>> Abel
>>
>>
>> > -----Original Message-----
>> > From: Costello, Roger L. costello@xxxxxxxxx [mailto:xsl-list-
>> > service@xxxxxxxxxxxxxxxxxxxxxx]
>> > Sent: Saturday, September 06, 2014 11:47 AM
>> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>> > Subject: [xsl] How to output the start execution time and the end
>> > execution
>> > time?
>> >
>> > 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
>> >
>>
>
> XSL-List info and archive
> EasyUnsubscribe (by email)



-- 
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
Keywords