|
Boost : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-12-19 11:26:00
Hi, I've just tried to measure performance of Boost.Function and Boost.Signals
using the following simple program:
#include <boost/function.hpp>
#include <boost/signals.hpp>
using namespace std;
void do_nothing() {}
int main()
{
boost::function<void (void)> f = do_nothing;
void (*pf)(void) = &do_nothing;
boost::signal<void (void)> s;
s.connect(&do_nothing);
for(int i = 0; i < 10000000; ++i)
s();
return 0;
}
and trying calls to 's()', 'pf()' and 'f()'. The timings are, on an Athlon
1700 with g++ 3.3.5 and -O3:
Function pointer: 0.05 secs
Boost.Function: 0.2 secs
Boost.Signals: 9.8 secs
Boost.Function is 4 times slower than function pointer, which seems decent for
me (not that I mind further improvement). But Boost.Signals is nearly 50
times slower that Boost.Function, and nearly 200 times slower than function
pointer.
Any chance this will be improved? Say, I don't care about combining the
results of signals invocation, or any connection tracking -- I just want to
use boost::signals as more convenient variant of vector<boost::function>. Is
it possible to have some preprocessor define that throws away all advanced
functionality? Or a base class, say "lightweight_signal" that has only
basics?
TIA,
Volodya
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk