on the speed of std::string::find
Paolo Carlini
pcarlini@suse.de
Fri Sep 1 11:13:00 GMT 2006
Paolo Carlini wrote:
> Dennis Lubert wrote:
>
>> Hello,
>>
>> I recently did some profiling of my application (compiled with gcc 4.1)
>> using callgrind (part of valgrind). I found out that the good old
>> std::strstr is between 4 and 20 times faster than std::string::find.
>>
> First, which version of gcc are you using? Recent versions simply
> delegate to the std::search in <algorithm>, which was benchmarked to
> be much faster than an algorithm based on char_traits::find, thus
> memchr, basically.
Actually, the old algorithm was based on char_traits::compare, thus
memcmp. Anyway...
Paolo.
More information about the Libstdc++
mailing list