
Alex Besogonov wrote:
Peter Dimov wrote:
Anyway, I committed a storage optimization to the CVS. <crosses fingers> Whoa! That's fast: ================================ C:\temp\delegates>test.exe Time elapsed for FastDelegate: 0.560000 (sec) Time elapsed for simple bind: 0.411000 (sec) Time elapsed for bind+function: 1.983000 (sec) Time elapsed for pure function invocation: 0.781000 (sec) ================================ bind+function<> is now just 4 times slower than the best possible case.
BTW, why not add FastDelegate (it's in public domain) to bind+function<> as a special case for optimization?
Most of the time is probably due to function<>'s dynamic dispatch mechanism; I'm not sure how FastDelegate can help. You could also try a test using ct_mem_fn< void (X::*)(), &X::f > where ct_mem_fn is: template< class Pm, Pm pm > struct ct_mem_fn { typedef void result_type; template<class A1> result_type operator()( A1 & a1 ) const { boost::mem_fn( pm )( a1 ); } template<class A1, class A2> result_type operator()( A1 & a1, A2 & a2 ) const { boost::mem_fn( pm )( a1, a2 ); } };