on the speed of std::string::find
Paolo Carlini
pcarlini@suse.de
Tue Sep 5 08:56:00 GMT 2006
Paolo Carlini wrote:
>> Dennis, thanks for your help, but something is certainly wrong in the
>> benchmarking, we can't trust it. Likely, it's because of the
>> optimization level, or something else. As I said already, you must
>> use -O2, otherwise we are measuring something which nobody will see
>> in practice.
>
> Just to say one, without inlining at -O0, going through type_traits
> (the tiny eq, in particular) means function calls which are certainly
> heavy to do for each char. This thing alone makes the "new"
> implementation appear much slower than memmem where the algorithm is
> in fact the same.
Anyway, something else must be also wrong in your testing, sorry. These
are the numbers I'm seeing on a P4-2400 from your fullwatch.cpp, -O0:
std::string::find : 1.53305
GNU memmem : 1.85151
Factor : 0.827999
Paolo.
More information about the Libstdc++
mailing list