Subject: Re: [xsl] Here's how to benchmark your XSLT program's execution time From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 6 Nov 2014 22:39:46 -0000 |
This test tells me that I get different values for two calls to the date:getDateType(Date.new()) expression. The loop is just there to take some time so that the start end/time should be different. I'm using this time-capture technique in practice to try to do some focused timing tests on a operations that involve operating on 1000s of files referenced from a DITA map, where the total time taken for that part of the processing is a significant fraction of the total processing: where is the time being taken up? There are two parts to that processing: resolving the link to the document and applying templates to the linked file. I wasn't sure which of these two processes was taking up the time: since this is early in the map processing there was a possibility that the parsing itself could be the time user. In my real example it's telling me that resolving the URI references (that is, using the document() function) is taking zero time (which is what I would expect since the referenced documents are either very small or have already been parsed earlier in the XSLT processing and I'm using a Xerces grammar cache) and that the per-file processing is taking up to 0.5 seconds per file (but usually only a few 100th or 10ths of a second). So either there are some problematic input files or I've got some inefficient code in the context of some files. Cheers, E. bbbbb Eliot Kimber, Owner Contrext, LLC http://contrext.com On 11/6/14, 11:44 AM, "Wolfgang Laun wolfgang.laun@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: >What does this tell you? The time for 10...0 iterations of an >xsl:for-each? Or of an xsl:variable? Or an xsl:sequence? Or how well >equipped your system is to output text to standard output? > > >I'd like to know the cost of one iteration plus the creation of a >variable. > > >-W > > > > > >On 6 November 2014 18:09, Eliot Kimber ekimber@xxxxxxxxxxxx ><xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > >Here's my test: > ><?xml version="1.0" encoding="UTF-8"?> ><xsl:stylesheet version="2.0" >xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:df="http://dita2indesign.org/dita/functions" >xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:relpath="http://dita2indesign/functions/relpath" >xmlns:glossdata="http://dita4publishers.org/glossdata" > xmlns:applicability="http://dita4publishers.org/applicability" > xmlns:mapdriven="http://dita4publishers.org/mapdriven" > xmlns:local="urn:functions:local" >xmlns:index-terms="http://dita4publishers.org/index-terms" > xmlns:date="java:java.util.Date" > xmlns:enum="http://dita4publishers.org/enumerables" >exclude-result-prefixes="local xs df xsl relpath glossdata date"> > > <xsl:template match="/" name="start"> > <xsl:variable name="startTime" select="date:getTime(date:new())"/> > <xsl:message> + [DEBUG] Start time: <xsl:value-of >select="$startTime"/> milliseconds</xsl:message> > <xsl:for-each select="1 to 100000000"> > <xsl:variable name="foo" select="."/> > <xsl:sequence select="$foo"/> > </xsl:for-each> > <xsl:variable name="endTime" select="date:getTime(date:new())"/> > <xsl:message> + [DEBUG] End time: <xsl:value-of select="$endTime"/> >milliseconds</xsl:message> > <xsl:variable name="elapsed" as="xs:integer" select="$endTime - >$startTime"/> > <xsl:message> + [DEBUG] Elapsed time: <xsl:value-of select="$elapsed >div 1000"/> seconds</xsl:message> > > </xsl:template> > ></xsl:stylesheet> > > >Which produces this result for me when run from Oxygen: > >+ [DEBUG] Start time: 1415293570616 >+ [DEBUG] End time: 1415293596900 >+ [DEBUG] Elapsed time: 26.284 seconds > >Cheers, > > >E. >bbbbb >Eliot Kimber, Owner >Contrext, LLC >http://contrext.com > > > > >On 11/6/14, 9:05 AM, "Costello, Roger L. costello@xxxxxxxxx" ><xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > >>> Order of evaluation is undefined in XSLT, and there is no guarantee >>> that $start is evaluated before the apply-templates call is evaluated. >> >>Yikes! >> >>So how do I write the XSLT program so that it is guaranteed that $start >>will be evaluated before the apply-templates call is evaluated? >> >>/Roger >> >>-----Original Message----- >>From: Michael Kay mike@xxxxxxxxxxxx >>[mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx] >>Sent: Thursday, November 06, 2014 9:49 AM >>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx >>Subject: Re: [xsl] Here's how to benchmark your XSLT program's execution >>time >> >>If this is working, then it's only by chance. >> >>Order of evaluation is undefined in XSLT, and there is no guarantee that >>$start is evaluated before the apply-templates call is evaluated. >> >>I think this only works in Saxon because the optimizer treats calls on >>extension functions as suspicious, and tries to avoid over-optimizing >>them because of potential side-effects. >> >>Michael Kay >>Saxonica >>mike@xxxxxxxxxxxx >>+44 (0) 118 946 5893 <tel:%2B44%20%280%29%20118%20946%205893> >> >> >> >> >>On 6 Nov 2014, at 10:20, Costello, Roger L. costello@xxxxxxxxx >><xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: >> >>> Hi Folks, >>> >>> So, you've got an XSLT program that is taking a long time to execute. >>>You want to find out what part of the program is taking so much time. >>>You need to insert some start/stop timers into your XSLT. Here's how to >>>do it: >>> >>> <?xml version="1.0" encoding="UTF-8"?> >>> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >>> xmlns:date="java:java.util.Date" >>> version="2.0"> >>> >>> <xsl:output method="text" /> >>> <xsl:output name="text-format" method="text"/> >>> >>> <xsl:template match="/"> >>> <!-- Start a timer --> >>> <xsl:variable name="start" select="date:getTime(date:new())" /> >>> >>> <!-- Do your XSLT processing --> >>> <xsl:apply-templates /> >>> >>> <!-- End the timer --> >>> <xsl:variable name="end" select="date:getTime(date:new())" /> >>> >>> <!-- Log the benchmarking results to a file, time-info.txt --> >>> <xsl:result-document href="time-info.txt" format="text-format"> >>> start: <xsl:value-of select="$start" /> >>> end: <xsl:value-of select="$end" /> >>> diff: <xsl:value-of select="$end - $start" /> >>> </xsl:result-document> >>> >>> </xsl:template> >>> >>> <xsl:template match="*"> >>> <!-- Do something --> >>> <xsl:text>Hello World </xsl:text> >>> <xsl:value-of select="current-dateTime()" /> >>> </xsl:template> >>> >>> </xsl:stylesheet> >>> >> >> > > > > > > > > >XSL-List info and archive ><http://www.mulberrytech.com/xsl/xsl-list>EasyUnsubscribe ><-list/1278982> >(by email <>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Here's how to benchmark y, Eliot Kimber ekimber | Thread | Re: [xsl] Parse a date - exslt:pars, Kerry, Richard richa |
Re: [xsl] Here's how to benchmark y, Wolfgang Laun wolfga | Date | Re: [xsl] Here's how to benchmark y, Abel Braaksma (Exsel |
Month |