Boost logo

Boost :

Subject: [boost] [algorithm] any_of does not call std::find - bad performance
From: Albert Yiamakis (vkicefire_at_[hidden])
Date: 2014-04-15 05:50:14


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk