Re: [xml] Performance of DOM interface

On Mon, Aug 26, 2002 at 01:44:51PM +0200, wellnhofer aevum de wrote:
hi nick,
hi list,

Matt Sergeant wrote:
On Saturday, August 24, 2002, at 07:12 PM, Nick Wellnhofer wrote:
Daniel Veillard wrote:
On Sat, Aug 24, 2002 at 03:13:08PM +0200, wellnhofer aevum de wrote:

I'm using libxml and libxslt with Perl to generate dynamic HTML 
pages and did some performance testing recently. I created a XML 
tree from a Perl data structure using the DOM interface and 
transform that tree with XSLT.

Yeah, it's all the method calls, and also the memory allocation and the 
reference counting that the Perl level API has to do, but the C one 
doesn't. It *might* be quicker to do it in perl-space and create an XML 
string and then parse it.

I just replaced the following Perl code to create a XML element 
containing only text

      my $child = $doc->createElement($k);
      my $text = $doc->createTextNode($v);

with the equivalent

      $node->appendTextChild($k, $v);

Building the DOM tree is now two times faster, but still a little slower 
than the XSLT transformation.

a major diffrerence between libxml2 and its Perl interface is the fact, that 
in C you can leave the memory management to a user while you can't in perl.
thus the module has to do all management itself.

through this you will loose a lot performance while the modules does not
cause memory leaks. there are still some obvious issues that slow XML::LibXML 
down a 'bit'.

i tried to add some functions to avoid some perl overhead during DOM building,
such as appendTextChild(), which is the reason why this significantly speeds 
the processing up.

christian glahn

Nick Wellnhofer

xml mailing list, project page
xml gnome org

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