lmi
[Top][All Lists]
Advanced

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

Re: [lmi] Ledger::write() -- adding DOCTYPE support to xmlwrapp?


From: Vaclav Slavik
Subject: Re: [lmi] Ledger::write() -- adding DOCTYPE support to xmlwrapp?
Date: Wed, 17 Dec 2008 00:52:19 +0100

Hi,

On Sat, 2008-12-13 at 16:54 +0000, Greg Chicares wrote:
>   Read    : 125%  <-- There's the 25% difference.

Interestingly, the difference is only 6% here (on Linux) and
implementing elements iterator in a manner analogous to
xml::node::find() doesn't improve things significantly (5% vs. 6%).

I'm almost sure the reason for this is xmlwrapp's liberal use of the
pimpl idiom. In particular, creating a new xml::node::(const_)iterator
instance results in one use of operator new. And find() creates at least
one iterator (with possibly more copies depending on the compiler).

Under this theory, your code is fast because it only creates a single
iterator instance and then increments it, rather than creating lots of
them. A simple change of ++child into child++ results in ~2-3%
performance drop, this suggests that this assumption is correct.

Clearly, using an elements-only iterator (where operator++ goes to the
next element, not node) instead of find()-like API will help with
performance, then. But perhaps we should consider improving performance
of the iterators in general too, because people are used to having cheap
iterators and to e.g. call end() in a loop:

        for(child = x.begin(); child != x.end(); ++child)

Regards,
Vaclav





reply via email to

[Prev in Thread] Current Thread [Next in Thread]