How do I time my XSLT execution times to millisecond accuracy?

I have an XSLT (running under Sitecore) that I'd like to benchmark.

For example:

<xsl:variable name="start_ms" select="TIME IN MILLIS" /> Do something <xsl:variable name="end_ms" select="TIME IN MILLIS" /> <xsl:variable name="total_ms" select="$end_ms - $start_ms" /> Do something else

Unfortunately I can't manage to get the time to milliseconds accuracy.

If I include xmlns:date="http://exslt.org/dates-and-times" I get date:dateTime(), but that only goes to seconds accuracy.

Similarly, sc:formatdate(sc:isoNow(),'ss.ffff') also only goes to seconds accuracy.

The Sitecore "debug page" functionality will tell me how long it takes to run the entire XSLT, but it wont let me benchmark individual components of the XSLT.

Is there any way to do this?

Answer1:

The Sitecore "debug page" functionality will tell me how long it takes to run the entire XSLT, but it wont let me benchmark individual components of the XSLT.

Is there any way to do this?

<strong>This strongly depends on the XSLT processor you are using, and the results generally maynot be trustworthy</strong>.

Even if you write your own extension functions and call them from the XSLT code (which seems to be the only way to achieve the desired timing precision), nothing guarantees that the extension function would be called when expected. or that it won't be called more than once when one call is expected. This is because we cannot predict and anticipate the decision of the optimizer used by a particular XSLT processor.

Some XSLT processors implement lazy evaluation -- an expression isn't evaluated unless it has become absolutely necessary for producing the result. Such a processor would execute the call to the timing extension function only when its result is used -- and that may be at the end of the measured processing -- so in this case any measured processing would be "instantaneous".

Answer2:

if you are trying to identify a processing bottleneck, you can move the separate components one by one into a new XSLT, taking millisecond benchmarks at each step using the debug tool.

人吐槽 人点赞

Recommend

Comment

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:How do I time my XSLT execution times to millisecond accuracy?