26675

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

  • How can I be getting multiple unwanted event blocks from the same onFormSubmit Trigger?
  • Using a custom class file in Umbraco XSLT
  • Relative time function in js for format YYYY-MM-DDTHH:MM:SS+0000
  • how to show only two items in xslt?
  • PHP create range of dates
  • Does using package generics require the package to be in Depends or Imports?
  • Obtain access token for both Microsoft Graph and individual service API endpoints (Outlook REST APIs
  • How to make a div appear under button
  • MS SQL Server 2008 :Getting start date and end date of the week to next 8 weeks
  • html5 tag support
  • How to create a generic Task.ContinueWith extension method
  • QObject::findChild() returns None without obvious reason
  • How to parse utc date
  • Kentico Repeater HTML Properties showing with selected transformation
  • What's the alternative to IValueFormatter in AutoMapper?
  • Running sp_executesql query expects parameter @statement
  • How to parsing NSDate to RFC 822 always use in English?
  • date: illegal option — d, Find difference between two dates
  • Aggregating two data frame columns without any existing pattern logic
  • How to get ID of changed file on Google Drive
  • How to set infinite shared access signature policy in azure?
  • data.table replicate rows after join?
  • Entire JSON into One SQLite Field with Python
  • stop execution in Custom validator if it false
  • Why are “sc.addFile” and “spark-submit --files” not distributing a local file to all workers?
  • pickle.PicklingError: args[0] from __newobj__ args has the wrong class with hadoop python
  • Easiest way to get current unix timestamp via XSL
  • Add dynamic data to line chart from mysql database with highcharts
  • python script hangs on input method when running spark
  • Extract zip entries to another Zip file
  • ActiveRecord query for a count of new users by day
  • Q promise. Difference between .when and .then
  • Cannot connect to cassandra from Spark
  • Illegal mix of collations for operation for date/time comparison
  • Cross-Platform Protobuf Serialization
  • Microsoft Visual Studio Community 2015 always crashes in Windows 10 if swithed to Visual FoxPro
  • Alternatives to the OPTIONAL fallback SPARQL pattern?
  • retrieve vertices with no linked edge in arangodb
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • How can I use threading to 'tick' a timer to be accessed by other threads?