|
Boost Users : |
Subject: Re: [Boost-users] boost::function performance issues with C++11
From: Ben Pope (benpope81_at_[hidden])
Date: 2014-07-09 00:05:48
On Tuesday, July 08, 2014 06:11 PM, Adam Romanek wrote:
>
> As promised I performed a simple test during the weekend and wasn't able
> to reproduce the issue. See the code below:
>
> ---
> #include <vector>
> #include <boost/bind.hpp>
> #include <boost/function.hpp>
>
> void call(boost::function<int ()> f) {
> f();
> }
>
> long long total = 0;
>
> int func2(std::vector<int> i){
> total += i.size();
> return i.size();
> }
>
> int main() {
> std::vector<int> v(100);
> const int T = 1000000;
> // s = boost::chrono::system_clock::now();
> for (int i = 0; i < T; ++i)
> call(boost::bind(&func2, v));
> // e = boost::chrono::system_clock::now();
> }
> ---
>
> The performance does not change when compiling with -std=c++11 or
> without it. I compile the code like this:
>
> $ g++ -I/home/A.Romanek/tmp/boost/boost_1_55_0 main.cpp -std=c++11 -O2
> && time ./a.out
>
> real 0m1.669s
>
> My setup is Ubuntu 14.04, gcc 4.8.2 and my CPU is Intel Core2Duo P8700 @
> 2.53GHz.
>
> Could you please provide a complete example so that I could reproduce
> the issue on my desk?
Make of this what you will, I used your example:
g++-4.8.2
-std=c++03 -std=c++11
real 0m0.753s 0m0.798s
user 0m0.752s 0m0.797s
sys 0m0.001s 0m0.002s
g++-4.9
-std=c++03 -std=c++11
real 0m0.786s 0m1.419s
user 0m0.785s 0m1.418s
sys 0m0.001s 0m0.002s
clang++-3.4 (libstdc++ from g++-4.9)
-std=c++03 -std=c++11
real 0m0.799s 0m1.407s
user 0m0.798s 0m1.406s
sys 0m0.001s 0m0.002s
clang++-3.4 (libc++ trunk)
-std=c++03 -std=c++11
real 0m1.382s 0m1.389s
user 0m1.381s 0m1.387s
sys 0m0.002s 0m0.002s
clang++-3.5 (libstdc++ from g++-4.9)
-std=c++03 -std=c++11
real 0m0.812s 0m1.112s
user 0m0.811s 0m1.111s
sys 0m0.002s 0m0.002s
clang++-3.5 (libc++ trunk)
-std=c++03 -std=c++11
real 0m0.782s 0m0.770s
user 0m0.781s 0m0.769s
sys 0m0.002s 0m0.002s
Ben
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net