[xslt] libxslt performance



  Hello,

  I think I have some performance problems with libXslt in xml --> rtf
  transformation. I compare 4 xslt-processors (xalan, saxon, msxml, xsltproc).
  Below You can see:
  1. My system's info.
  2. .bat Windows script
  3. Input xml-file.
  4. Results of timing for all 4 xslt-processors.
  5. Result of "xsltproc --profile" command at Win2k
  6. Result of "xsltproc --profile" command at HP-UX (sorry, I have
  not there any other xslt-processors)

  My xsl-file is in attach (5 k). I know that it's not optimized, but
  it can show the difference in performance. Sorry if it's not minimal
  but the result is valid rtf ;)

  I wonder if such difference in performance (300 secs vs. 3-18 secs)
  between xsltproc and other xslt-processors is right? Where can be
  the cause? I can provide any additional info.


  Thank You in advance for any help.

  Alexey.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1. My system's info.

  CPU: Intel Pentium III 733 MHz
  OS: Windows 2000 Server
  Ram: 128 M

  Soft versions:
>>>>>>> Xalan Version 2.0.1, <<<<<<<

SAXON 6.5.2 from Michael Kay

Microsoft (R) XSLT Processor Version 3.0

Using libxml 20501, libxslt 10023 and libexslt 714
xsltproc was compiled against libxml 20428, libxslt 10023 and libexslt 714
libxslt 10023 was compiled against libxml 20428
libexslt 714 was compiled against libxml 20428
  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. .bat Windows script

C:\efim_data\xml\speed_test>more speed_test.bat
echo off
set home=C:\bin\xml
set dir=C:\efim_data\xml\speed_test
set xml=%dir%\long_test.xml
set xsl=%dir%\min_rtf_col.xsl

echo ---- xalan ----
java -jar %home%\xfc\xalan.jar -DIAG -IN %xml% -XSL %xsl% -OUT xalan.rtf

echo ---- saxon ----
java -jar %home%\saxon\saxon6_5_2\saxon.jar -t -o saxon.rtf %xml% %xsl%

echo ---- msxml ----
%home%\msxml\msxsl.exe %xml% %xsl% -o msxml.rtf -t

echo ---- libxml ----
%home%\libxml\common\xsltproc.exe --timing --output libxml.rtf %xsl% %xml%

echo ---- end of speed test ----

C:\efim_data\xml\speed_test>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. Input xml-file.

<?xml version="1.0" encoding="koi8-r"?>
<blocks type="details">

<table spaceUp="0" percentWidth="100" border="1" colNum="6">
<body>
<row>
  <col id="1" percentWidth="15">01.04.02 09:01</col> 
  <col id="2" percentWidth="15">PBX_Orlenok.7</col> 
  <col id="3" percentWidth="15">133</col> 
  <col id="4" percentWidth="20">Îðõìþâ 99999999999</col>
  <col id="5" percentWidth="15">0.000 min</col>
  <col id="6" percentWidth="15">0.000</col> 
  </row>
<!-- ..... this row is repeated 12630 times. I CAN send full xml-file
(672 k) if anybody wishs -->
</body>
</table>
</blocks>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. Results of timing for all 4 xslt-processors.

C:\efim_data\xml\speed_test>speed_test.bat

C:\efim_data\xml\speed_test>echo off
---- xalan ----
...
Transform of C:\efim_data\xml\speed_test\long_test.xml via C:\efim_data\xml\spee
d_test\min_rtf_col.xsl took 18627 ms

---- saxon ----
SAXON 6.5.2 from Michael Kay
Java version 1.3.1_01
Preparation time: 441 milliseconds
Processing file:/C:/efim_data/xml/speed_test/long_test.xml
Building tree for file:/C:/efim_data/xml/speed_test/long_test.xml using class co
m.icl.saxon.tinytree.TinyBuilder
Tree built in 941 milliseconds
Execution time: 3735 milliseconds

---- msxml ----
Microsoft (R) XSLT Processor Version 3.0

Source document load time:     454.4 milliseconds
Stylesheet document load time: 3.709 milliseconds
Stylesheet compile time:       17.53 milliseconds
Stylesheet execution time:     2944 milliseconds

---- libxml ----
Parsing stylesheet C:\efim_data\xml\speed_test\min_rtf_col.xsl took 0 ms
Parsing document C:\efim_data\xml\speed_test\long_test.xml took 340 ms
Running stylesheet and saving result took 292110 ms
---- end of speed test ----

C:\efim_data\xml\speed_test>
  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. Result of "xsltproc --profile" command at Win2k

C:\efim_data\xml\speed_test>%home%\libxml\common\xsltproc.exe --timing --noout -
-profile %xsl% %xml%
Parsing stylesheet C:\efim_data\xml\speed_test\min_rtf_col.xsl took 0 ms
Parsing document C:\efim_data\xml\speed_test\long_test.xml took 340 ms
number               match                name      mode  Calls Tot 100us Avg

    0                  col                          text  12630 15715807   1244
    1                  col                           def  12630 5537455    438
    2                             choose-align            12630 5325052    421
    3                  row                                 2105 2678909   1272
    4           table/body                                    1  10270  10270
    5               blocks                                    1    852    852
    6                               get-border                1      4      4
    7                table                                    1      2      2

                         Total                            39999 29268351
Applying stylesheet took 292741 ms

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. Result of "xsltproc --profile" command at HP-UX

>/www/xml/xsl/bin/xsltproc --noout --profile --timing min_rtf_col.xsl long_test.xml
Parsing stylesheet min_rtf_col.xsl took 10 ms
Parsing document long_test.xml took 1655 ms
number               match                name      mode  Calls Tot 100us Avg

    0                  col                          text  12630 17202548   1362
    1                  col                           def  12630 7209202    570
    2                             choose-align            12630 6374858    504
    3                  row                                 2105 2979272   1415
    4           table/body                                    1  12408  12408
    5               blocks                                    1   1078   1078
    6                               get-border                1     20     20
    7                table                                    1      5      5

                         Total                            39999 33779391
Applying stylesheet took 337850 ms

>/www/xml/xsl/bin/xsltproc -V
Using libxml 20421, libxslt 10016 and libexslt 707
xsltproc was compiled against libxml 20421, libxslt 10016 and libexslt 707
libxslt 10016 was compiled against libxml 20421
libexslt 707 was compiled against libxml 20421

>uname -mrsv
HP-UX B.11.00 A 9000/800
  
~~~~~~~~~~~~~~~~~~~~~~~ end of message ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<?xml version="1.0"	encoding="koi8-r"?>
<xsl:stylesheet	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output	method="text" indent="no" omit-xml-declaration="yes" encoding="koi8-r"/>

<!-- GLOBAL	VARIABLES -->
<xsl:variable name="paperwidth">11906</xsl:variable>	<!-- 210 mm	-->
<xsl:variable name="paperheight">16838</xsl:variable>	<!-- 297 mm	-->
<xsl:variable name="leftmargin">794</xsl:variable>		<!-- 14	mm -->
<xsl:variable name="rightmargin">907</xsl:variable>		<!-- 16	mm -->
<xsl:variable name="topmargin">1440</xsl:variable>		<!-- 1 inch	-->
<xsl:variable name="bottommargin">1440</xsl:variable>	<!-- 1 inch	-->
<xsl:variable name="pagewidth" select="$paperwidth - $leftmargin - $rightmargin"/>

<xsl:variable name="arial10L">\f1\fs20\ql </xsl:variable>
<xsl:variable name="arial10R">\f1\fs20\qr </xsl:variable>
<xsl:variable name="arial10C">\f1\fs20\qc </xsl:variable>
<xsl:variable name="rowDef">\pard\trowd \trql\trgaph0\trrh0\trleft10</xsl:variable>
<xsl:variable name="cellBorder1">\clbrdrt\brdrs \clbrdrl\brdrs \clbrdrb\brdrs \clbrdrr\brdrs</xsl:variable>
<xsl:variable name="cellBorder2">\clbrdrt\brdrdb \clbrdrl\brdrdb \clbrdrb\brdrdb \clbrdrr\brdrdb</xsl:variable>

<xsl:variable name="fontHeight">10</xsl:variable>
<!-- END OF	GLOBAL VARIABLES -->

<xsl:template name="get-border">
	<xsl:param name="width">1</xsl:param>
	<xsl:choose>
		<xsl:when test="$width = '0'"> 
			<xsl:text> </xsl:text> 
		</xsl:when>
		<xsl:when test="$width = '2'"> 
			<xsl:value-of select="$cellBorder2"/>
		</xsl:when>
		<xsl:otherwise>	
			<xsl:value-of select="$cellBorder1"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template name="choose-align">
	<xsl:param name="currPos">1</xsl:param>
	<xsl:param name="lastPos">1</xsl:param>

	<xsl:choose>
		<xsl:when test="$currPos = 1"> 
			<xsl:value-of select="$arial10L"/>
		</xsl:when>
		<xsl:when test="$currPos = $lastPos"> 
			<xsl:value-of select="$arial10R"/>
		</xsl:when>
		<xsl:otherwise>	
			<xsl:value-of select="$arial10C"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="blocks">
<!-- RTF HEADER	-->
	<xsl:value-of select="concat('{\rtf1\ansi\deff1\deftab720\paperw',$paperwidth,'\paperh',$paperheight,'\margl',$leftmargin,'\margr',$rightmargin,'\margt',$topmargin)"/>
	<xsl:value-of select="concat('\margb',$bottommargin)"/>
<!-- FONT TABLE	--><!--	STYLE TABLE	-->
	<xsl:text>
{\fonttbl
{\f0\fnil MS Sans Serif;}
{\f1\fmodern\fcharset204{\*\fname Courier New;}Courier New Cyr;}
{\f2\fswiss\fcharset204{\*\fname Arial;}Arial Cyr;}}
{\stylesheet
{\s0\f2\fs20\ql Arial10Left;}
{\s1\f2\fs20\qc\snext2 Arial10Center;}
{\s2\qr\sbasedon0\snext0 Arial10Right;}}
{\windowcaption ïÔÞ£ÔÎÙÊ ÄÏËÕÍÅÎÔ}</xsl:text>

	<xsl:apply-templates select="*"/>

<!-- add empty	-->
	<xsl:text>}&#10;</xsl:text>
</xsl:template>

<xsl:template match="table">
	<xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="table/body">
	<xsl:variable name="maxColNum" select="../@colNum"/>

	<xsl:variable name="borderDef">
		<xsl:call-template name="get-border">
			<xsl:with-param	name="width" select="../@border"/>
		</xsl:call-template>
	</xsl:variable>

	<xsl:variable name="parentWidth" select="../@percentWidth"/>

	<xsl:apply-templates select="row">
		<xsl:with-param	name="parentWidth" select="$parentWidth"/>
		<xsl:with-param	name="borderDef" select="$borderDef"/>
	</xsl:apply-templates>
</xsl:template>

<xsl:template match="row">
	<xsl:param name="parentWidth"/>
	<xsl:param name="borderDef"/>

	<xsl:value-of select="concat('&#10;', $rowDef)"/>

<!-- Define cols -->
	<xsl:apply-templates select="col" mode="def">
		<xsl:with-param	name="parentWidth" select="$parentWidth"/>
		<xsl:with-param	name="borderDef" select="$borderDef"/>
	</xsl:apply-templates>

	<xsl:text>&#10;</xsl:text>

<!-- Insert cols -->
	<xsl:apply-templates select="col" mode="text"/>

	<xsl:text> \row </xsl:text>
</xsl:template>

<xsl:template match="col" mode="def">
	<xsl:param name="parentWidth"/>
	<xsl:param name="borderDef"/>

<!-- IF NEXT COL'S ID != (THIS COL'S ID + 1) WE MERGE CELLS -->
<xsl:variable name="width">
	<xsl:choose>
		<xsl:when test="position()=last()">
			<xsl:value-of select="round($pagewidth*$parentWidth div 100)"/>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="round($pagewidth*$parentWidth*(100 - sum(following-sibling::col/@percentWidth)) div 10000)"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:variable>

	<xsl:value-of select="concat($borderDef, '\cellx', $width)"/>
</xsl:template>

<xsl:template match="col" mode="text">
		<xsl:text>\pard\intbl </xsl:text>

		<xsl:call-template name="choose-align">
			<xsl:with-param	name="currPos" select="position()"/>
			<xsl:with-param	name="lastPos" select="last()"/>
		</xsl:call-template>

		<xsl:apply-templates/>
		<xsl:text>\cell</xsl:text>
</xsl:template>

</xsl:stylesheet>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]