doekman / xml2json-xslt

Automatically exported from code.google.com/p/xml2json-xslt
BSD 3-Clause "New" or "Revised" License
38 stars 17 forks source link

Dismal performance against node with 500 children #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I benchmarked xml2json-xslt against a select node with 500 child option nodes.

time xsltproc --profile xml2json.xsl testselect.xml

real    0m18.185s
user    0m18.100s
sys 0m0.000s

Ouch.

I searched around a bit and found a version which Martynas Jusevičius modified 
to add attribute and array support.

time xsltproc --profile xml2json-martynas.xsl testselect.xml

real    0m0.046s
user    0m0.040s
sys 0m0.010s

Perhaps his changes could be integrated to greatly improve the performance of 
xml2json-xslt? The output is different (the array is at object.select.option 
instead of object.select, actually arguably more sensible), but for how I'm 
using it, modifying my Javascript to accommodate this is trivial.

Benchmark conducted on HP Compaq nc6400 with Intel(R) Core(TM)2 CPU T7200  @ 
2.00GHz and 4GB RAM running Ubuntu 10.04 64-bit.

Original issue reported on code.google.com by colind...@gmail.com on 17 Jun 2010 at 4:10

Attachments:

GoogleCodeExporter commented 9 years ago
Probably a problem of xsltproc. On Windows 2000 with msxsl.exe it's fractions 
of a second:

  @echo off
  cls
  echo Start 
  echo. | time
  msxsl.exe testselect.xml xml2json.xsl -o own.json.txt
  echo Stop
  echo. | time
  echo --------------------------------------------
  echo Start 
  echo. | time
  msxsl.exe testselect.xml xml2json-martynas.xsl -o xml2json-martynas.json.txt
  echo Stop
  echo. | time

Output:

  Start
  The current time is: 22:38:23,54
  Enter the new time:
  Stop
  The current time is: 22:38:23,82
  Enter the new time:
  --------------------------------------------
  Start
  The current time is: 22:38:23,84
  Enter the new time:
  Stop
  The current time is: 22:38:23,91
  Enter the new time:

About the different output: we probably don't want to have breaking changes, 
but I'll leave it open for now.

Benchmarked using a Athlon(tm) XP 1800+ and 256MB RAM running Windows 2000 SP4

Original comment by doek...@gmail.com on 17 Jun 2010 at 8:44

GoogleCodeExporter commented 9 years ago
Interesting. Thanks for looking into it. I tested a little more, this time 
using PHP. It looks like it's a problem in libxml and/or libxslt.

[colin@vwing debug]$ php5 -a
Interactive shell

php > $xml = new DOMDocument();
php > $xml->load("testselect.xml");
php > $xslt = new XSLTProcessor();
php > $xsl = new DOMDocument();
php > $xsl->load("xml2json.xsl", LIBXML_NOCDATA);
php > $xslt->importStylesheet($xsl);
php > print $xslt->transformToXML($xml);
<output snipped>
php > $xsl = new DOMDocument();
php > $xsl->load("xml2json-martynas.xsl",LIBXML_NOCDATA);
php > $xslt->importStylesheet($xsl);
php > print $xslt->transformToXML($xml);
<output snipped>

I just wall-clocked it this time, and the time was approximately the same.

Original comment by colind...@gmail.com on 17 Jun 2010 at 9:16