$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: [boost] boost::signal poor performance
From: Hansi (hansipet_at_[hidden])
Date: 2008-09-22 02:14:11
Hello,
I have posted this already to the user list, maybe wrong forum...
I have made now a small test and I don't know if I make something wrong.
I have the following performance comparsion between a boost::function 
and a boost::signal.
Okay, I know that boost::signal has a lot of more functionality and for 
that it is for sure slower than boost::function. But 100times slower?
May be I do something wrong?
On my pc I have for boost::function a runtime of 728ms and for 
boost::signals a runtime of 64128ms
There is one slot used for signals.
Can anyone give me some hint what I do wrong?
my test program was:
class TestBind
{
public:
     int counter;
     void OnEventReceived(char b)
     {
         counter++;
     }
};
class TestSignal
{
public:
     int counter;
     void OnEventReceived(char b)
     {
         counter++;
     }
};
int _tmain(int argc, _TCHAR* argv[])
{
     TestBind testBind;
     PerformanceCounter timer;
     boost::function<void (char)> f = 
boost::bind(&TestBind::OnEventReceived,&testBind,_1);
     for(int i = 0; i < 100000000; i++)
     {
         f('a');
     }
     TestSignal testSignal;
     boost::signal<void (char)> sig;
     sig.connect(boost::bind(&TestSignal::OnEventReceived,&testSignal,_1));;
         for(int i = 0; i < 100000000; i++)
     {
         sig('a');
     }
}
Best regards
Hansjörg