Boost logo

Boost Users :

Subject: Re: [Boost-users] [Multi-Index] performance difference between lower_bound() and upper_bound()
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2013-11-21 11:38:10


Dominique Devienne <ddevienne <at> gmail.com> writes:

>
> I have a multi-index BMI (Boost 1.44), with an ordered_non_unique
> index on a"name" string field, which is lexicographically ordered.
> I'm searching for the range of values of the form "$prefix $integer",
> i.e. "foo 1", "foo 99", etc...
>
>
> to obtain this "range", I initially used (pseudo-code):
>
> auto begin = by_name_index().lower_bound(prefix + " 0");
> auto end = by_name_index().upper_bound(prefix + " 9");
>
>
> and within the range I test the suffix for its number'ness and keep the
> largest number.
>
> But I was surprised to see it performed badly for large number of calls.
>
> I switched to using instead:
>
>
> auto begin = by_name_index().lower_bound(prefix + " 0");
> auto end = by_name_index().lower_bound(prefix + " :");
>
>
>
> And this performs much better (20x).

There is no reason why it should, if both ops are returning the
sme range. Could you please show the customcomparison predicate you're
using? This might shed some light on the issue.

Thank you,

Joaquín M López Muñoz
Telefónica Digital


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