如何将 XSLT 执行时间计时到毫秒精度? [英] How do I time my XSLT execution times to millisecond accuracy?

查看:28
本文介绍了如何将 XSLT 执行时间计时到毫秒精度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 XSLT(在 Sitecore 下运行),我想对其进行基准测试.

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

例如:

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

如果我包含 xmlns:date="http://exslt.org/dates-and-times" 我得到 date:dateTime(),但那只是达到秒精度.

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

同样,sc:formatdate(sc:isoNow(),'ss.ffff') 也只能达到秒精度.

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

Sitecore调试页面"功能会告诉我运行整个 XSLT 需要多长时间,但它不会让我对 XSLT 的各个组件进行基准测试.

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?

推荐答案

Sitecore调试页面"功能会告诉我需要多长时间运行整个 XSLT,但它不会让我对个人进行基准测试XSLT 的组件.

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?

这在很大程度上取决于您使用的 XSLT 处理器,并且结果通常可能不可信.

即使您编写自己的扩展函数并从 XSLT 代码中调用它们(这似乎是实现所需计时精度的唯一方法),也不能保证扩展函数会在预期时被调用.或者在需要一次调用时不会多次调用它.这是因为我们无法预测和预测特定 XSLT 处理器使用的优化器的决策.

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.

某些 XSLT 处理器实现了惰性求值——除非对产生结果绝对必要,否则不会对表达式求值.只有在使用其结果时,这样的处理器才会执行对计时扩展函数的调用——这可能是在测量的处理结束时——所以在这种情况下,任何测量的处理都将是瞬时的".

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".

这篇关于如何将 XSLT 执行时间计时到毫秒精度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆