
Alex Besogonov <cyberax@elewise.com> writes: | You can see that boost::function + boost::bind is an order of | magnitude slower than FastDelegate. Even a mere invocation of a | boost::function is slower than complete bind+invoke for FastDelegate. This is a profile with a optimization and all inlining turned off: #include <stdio.h> #include <boost/timer.hpp> #include <boost/function.hpp> void test(int param) { int i = 0; i = param + 1; } void test3() { boost::timer t3; for(int f=0;f<100000000;f++) { boost::function<void(int)> func = &test; func(f); } printf("Time elapsed for bind+function: %f(sec)\n",t3.elapsed()); } int main(void) { test3(); return 0; } g++ -Wextra -Wall -pg -g -O0 -fno-inline-functions -fno-inline \ -fno-inline-functions-called-once -o function function.cxx Just the top of the profile: Flat profile: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls s/call s/call name 14.83 7.29 7.29 200000000 0.00 0.00 boost::detail::function::functor_manager<void (*)(int), std::allocator<void> >::manage(boost::detail::function::any_pointer, boost::detail::function::functor_manager_operation_type) 13.58 13.96 6.67 100000000 0.00 0.00 void boost::function1<void, int, std::allocator<void> >::assign_to<void (*)(int)>(void (*)(int), boost::detail::function::function_ptr_tag) 11.65 19.69 5.73 200000000 0.00 0.00 boost::function1<void, int, std::allocator<void> >::clear() 9.10 24.16 4.47 200000000 0.00 0.00 boost::detail::function::functor_manager<void (*)(int), std::allocator<void> >::manager(boost::detail::function::any_pointer, boost::detail::function::functor_manager_operation_type, boost::detail::function::function_ptr_tag) I have no idea if this is of any use to anyone. -- Lgb