[algorithm] any_of does not call std::find - bad performance
Hello, Is there a particular reason why Boost.Algorithm's any_of does not call std::find? I have devised a simple benchmark that shows it to perform much worse (compiling with gcc): http://pastebin.com/nrgtTfPX boost::find is almost as fast as std::find - no surprises, as it calls it. any_of is considerably slower, whatever the optimization level. I have not dug in the implementation of std::find to determine why; perhaps the compiler recognizes this is a sorted range, perhaps it's even capable of doing the calculation at compile time. Whatever the case however, surely any_of should also call std::find to reap the same benefits? Albert
Mistake - was calling boost::find and std::find on different number. Corrected: http://pastebin.com/uTaQapN5 any_of performance still inferior.
Hello, I have gone ahead and made a pull request implementing the change: https://github.com/boostorg/algorithm/pull/3 - All tests pass - The pull request is to master since it seems to be ahead of develop - The style is I suppose inconsistent with the library's (no spaces between parentheses and arguments) I noticed that any_of checks if C++11 is available and if so uses std::any_of. i) There is no such check for any_of_equal but it could also use std::any_of (the predicate being std::equal_to) ii) Shouldn't it check if the function is defined rather than C++ version? Albert
participants (1)
-
Albert Yiamakis