Boost logo

Boost Users :

Subject: Re: [Boost-users] How to improve property_tree performance
From: Bo Jensen (jensen.bo_at_[hidden])
Date: 2010-10-13 04:15:13


On Wed, Oct 13, 2010 at 8:09 AM, Sebastian Redl
<sebastian.redl_at_[hidden]> wrote:
> On 13.10.2010 09:35, Bo Jensen wrote:
>>
>> Hi,
>> I have a fairly easy record structure which I am writing to xml using
>> property_tree. I am trying to figure out how to do it better, since
>> the current time spend building the tree is too high.
>>
>> I do the following :
>>
>>     wiptree pt;
>>     wiptree&tvars = pt.add(L"some.recordname",L"");
>>
>>     for( int i = 0; i<  somenumber /*say 60K*/; ++i )
>>     {
>>       wiptree&curtree = tvars.add(L"someitem",L"");
>>
>>       curtree.add(L"<xmlattr>.name",L"some_attribute");
>>
>>       ...
>>     }
>>
>> To me this seems reasonable. Is there a faster way to do this ? Since
>> I just want to write it out and it's quite simple, I could avoid using
>> property_tree and write the xml file manually. But since I read it in
>> later with property_tree, then for maintainability I would like to
>> read and write with the same method.
>>
>
> I've never done a performance analysis of PTree (I hardly have time to get
> the docs up to date with the actual library), so I don't know what is fast
> and what is slow. PTree is definitely not a fast library. I have some ideas
> about how to make it faster, but that would take essentially a
> reimplementation of the ptree class.

I completely understand, I just wanted to eliminate me doing something stupid.

>
> You might want to try to use only push_back() instead of add(), though. That
> incurs fewer lookups and might thus improve performance.
>

I tried that, it was only slightly faster. I also tried to do a bunch
of independent trees and then merge them later, but still same speed.
Is it correct, that you can not choose the underlying storage method
or preallocate some space ? In my case I know exactly the sizes of
each tree and number of items.

Thanks for your time.

> Sebastian
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net