Re: [xml] Performance of DOM interface
- From: Matt Sergeant <matt sergeant org>
- To: Nick Wellnhofer <nick paradigmashift com>
- Cc: xml gnome org
- Subject: Re: [xml] Performance of DOM interface
- Date: Sun, 25 Aug 2002 21:49:45 +0100
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:
Hi,
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.
While the performance of the XSLT transformation is really good, I
found that constructing the DOM tree took about 75% of the running
time. So it takes about three times longer to create the XML source
tree than to parse a stylesheet and apply and output the
transformation.
Is this behavior normal? I would think creating an XML tree is much
faster than a XSLT transformation.
Well usually when creating the input tree using directly the C
parser,
the parse time (which includes building the DOM tree) is quite
smaller than
the tranformation time itself. So no it's not "normal", though it
also depends a lot on the stylesheet used too. You're probably paying
the cost
of going back and forth between the Perl and the C library for each
call to DOM entry points.
Yes, that seems to be the only explanation I can think of. The XSLT
transformation needs about 5 calls to the C library, but the creation
of the DOM tree requires hundreds of calls of createElement and
appendChild.
It might even be faster to generate XML directly in Perl and write it
to a file or memory buffer and then parse it with libxml again. I
think I will try that, although it seems like a stupid approach.
The best solution is probably a single Perl XS function that converts
a whole Perl data structure to a DOM tree in one go.
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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]