Boost logo

Boost :

Subject: Re: [boost] [filesystem] operator == performance
From: Beman Dawes (bdawes_at_[hidden])
Date: 2009-01-19 13:41:42


On Sat, Jan 17, 2009 at 6:11 AM, Konstantin Litvinenko
<to.darkangel_at_[hidden]> wrote:
> Hi!
>
> I am developing an application with very intensive boost::filesystem::path
> usage. At certain moment application start to be slowly and I start
> profiler. Profiler shows me that
> std::map<fs:path, ....>
> is painfully slow due path::operator <() that do
>
> lexicographical compare
>
> , that do
>
> void iterator_helper<Path>::do_increment( iterator & itr )
>
> that is really slow.
>
> So I have replaced std::map on boost::unordered_map.. and didn't get
> expected performance gain. Profiles show me that path::operator <() hit
> count 200000 and now only 100000. That tooooo much. Further investigation
> shows that problem was path::operator ==() used in unordered_map. I
> understand that operator == can be implemented using strict weak ordering
> concept, but for filesystem::path. Why not implement it as:
>
> bool path::operator == (const path& lhs, const path& rhs) const
> {
> return lhs.string() == rhs.string();
> }

Good question.

While the other relationals have to use
std::lexicographical_compare(), operators == and != can do a simple
string compare, as you suggest.

SVN trunk updated. It is a bit too late for these changes to make it
into 1.38.0, however.

It would be interesting if you could report back what impact that
change has on you timings.

Thanks,

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk