RE: [xsl] Efficient recursive grouping in XSLT 1.0?

Subject: RE: [xsl] Efficient recursive grouping in XSLT 1.0?
From: "Ian Young" <I.M.Young@xxxxxxxxxx>
Date: Sat, 20 Mar 2004 11:10:34 -0000
Thanks Mike,

# The thing that seems to make a dramatic difference to Saxon's speed on
# this transformation is to introduce a variable for the expression
# $parents/*,

That's _very_ interesting. What you posted speeded up Saxon's execution of 
the stylesheet to about 40% of the original time. However, combining your 
change with the mine (defering creation of the current-group variable to 
inside the xsl:if) gives Saxon run times that are not much slower than the 
XSLT 2.0 stylesheet.

  <xsl:template name="subtree">
    <xsl:param name="parents"/>
    <xsl:variable name="children" select="$parents/*"/>
    <xsl:for-each select="$children">
      <xsl:if test="count(($children[name() = name(current())])[1] | .) = 
1">
        <xsl:variable name="current-group"
            select="$children[name() = name(current())]"/>

Sadly it still doesn't make a difference to Libxslt.
So the tally stands like this:

PC: 1x 2GHz Athlon, 1GB RAM, Windows XP Pro

Transform
---------
uniqpath7.xslt   first stylesheet in imy mail (XSLT 2.0)
uniqpath8.xslt   second stylesheet in imy mail
uniqpath8k.xslt  8, modified as in mhk mail
uniqpath9.xslt   current-group created in xsl:if
uniqpath9k.xslt  combine changes of 8k and 9

Input       kB  elements  output kB elements
-----     ----  --------  --------- --------
cdfN.xml  1340     32072          3       55
PAD.xml   5125    131178         47     1055
PDRUG.xml 7468    163993         58     1029
cdfN4.xml  190      4490          3       52
[Sorry: I misread Saxon's node count as an element count previously]

Processor Version                    Command
--------- ------------------------   -------
Saxon   Saxon 7.9, Sun Java 1.4.2    java -jar saxon7.jar -t
MSXML   MSXML 4.0                    msxsl -t
LibXSLT LibXSLT 1.1.4, LibXML 2.6.7  xsltproc --timing

Input  Transform   Processor Time (ms)
-----  ----------  --------- ---------
cdfN   uniqpath7   Saxon           781
cdfN   uniqpath8   Saxon        324125
cdfN   uniqpath8k  Saxon        151609
cdfN   uniqpath9   Saxon        299156
cdfN   uniqpath9k  Saxon          1235
cdfN   uniqpath8   MSXML        131150
cdfN   uniqpath8k  MSXML        110169
cdfN   uniqpath9   MSXML           628
cdfN   uniqpath9k  MSXML           556
cdfN   uniqpath8   LibXSLT     >600000*
cdfN   uniqpath8k  LibXSLT     >300000*
cdfN   uniqpath9   LibXSLT     >300000*
cdfN   uniqpath9k  LibXSLT     >300000*
PAD    uniqpath7   Saxon          2578
PAD    uniqpath9k  Saxon          3828
PAD    uniqpath9   MSXML          2019
PAD    uniqpath9k  MSXML          1953
PDRUG  uniqpath7   Saxon          2891
PDRUG  uniqpath9k  Saxon          4094
PDRUG  uniqpath9   MSXML          2334
PDRUG  uniqpath9k  MSXML          2229
cdfN4  uniqpath8   LibXSLT       17828
cdfN4  uniqpath8k  LibXSLT       16250
cdfN4  uniqpath9   LibXSLT       16656
cdfN4  uniqpath9k  LibXSLT       14922

*aborted by user

Cheers,

Ian.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread