This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: on the speed of std::string::find


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]