Re: [Boost-users] [Asio]Question about error_code when socket::close
void Read() { // this line is very slow, // because boost::bind(&Session::HandleRead,shared_from_this(), ...) // causes extra new/delete operations
My test result: ---------------------------------- raw ptr version ------------------------ a.cc: class A { public: void f() {} }; int main() { A a; boost::function<void ()> f; for (size_t i = 0; i < 100000000; ++i) { f = boost::bind(&A::f, &a); } } gcc a.cc -O2 time ./a.out real 0m1.235s user 0m1.232s sys 0m0.000s ------------------------------------ shared_ptr version ---------------------- a.cc: class A { public: static void f(boost::weak_ptr<A>) {} }; int main() { boost::shared_ptr<A> a = boost::make_shared<A>(); boost::function<void ()> f; for (size_t i = 0; i < 100000000; ++i) { f = boost::bind(&A::f, a); } } gcc a.cc -O2 time ./a.out real 0m25.925s user 0m25.898s sys 0m0.000s
participants (1)
-
Comet