<br><br>
<div class="gmail_quote">2009/7/22 Frank Mori Hess <span dir="ltr">&lt;<a href="mailto:frank.hess@nist.gov" target="_blank">frank.hess@nist.gov</a>&gt;</span><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">-----BEGIN PGP SIGNED MESSAGE-----<br>Hash: SHA1<br>
<div><br>On Wednesday 22 July 2009, Sajjan Kalle wrote:<br>&gt; I did a search on the mailing list and found a<br>&gt; discussion from 2005 on the performance of the library, results at that<br>&gt; time showed a vector with boost::function being about 100 times faster than<br>
&gt; boost::signals.<br><br></div>You&#39;re going to have to provide a link.</blockquote>
<div>�</div>
<div>Old one <a href="http://aspn.activestate.com/ASPN/Mail/Message/boost/2239573">http://aspn.activestate.com/ASPN/Mail/Message/boost/2239573</a>�.</div>
<div>Found a more recent <a href="http://archives.free.net.ph/message/20080916.195431.40753f57.fr.html">http://archives.free.net.ph/message/20080916.195431.40753f57.fr.html</a>�.</div>
<div>�</div>
<div>I used the following:</div>
<div><font color="#0000ff" size="2"><font color="#0000ff" size="2">
<p>void</p></font></font><font size="2"> </font><font color="#030003" size="2"><font color="#030003" size="2">foo</font></font><font size="2">( )
<p>{</p>
<p>}</p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">
<p>int</p></font></font><font size="2"> </font><font color="#030003" size="2"><font color="#030003" size="2">main</font></font><font size="2">()
<p>{</p>
<p></p></font><font color="#030003" size="2"><font color="#030003" size="2">Altus</font></font><font size="2">::</font><font color="#030003" size="2"><font color="#030003" size="2">Timer</font></font><font size="2"> </font><font color="#030003" size="2"><font color="#030003" size="2">tim</font></font><font size="2">;
<p></p></font><font color="#030003" size="2"><font color="#030003" size="2">std</font></font><font size="2">::</font><font color="#030003" size="2"><font color="#030003" size="2">vector</font></font><font size="2">&lt; </font><font color="#030003" size="2"><font color="#030003" size="2">boost</font></font><font size="2">::</font><font color="#030003" size="2"><font color="#030003" size="2">function</font></font><font size="2">&lt; </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">void</font></font><font size="2"> ( </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">void</font></font><font size="2"> ) &gt; &gt; </font><font color="#030003" size="2"><font color="#030003" size="2">manualSignal</font></font><font size="2">;
<p></p></font><font color="#030003" size="2"><font color="#030003" size="2">boost</font></font><font size="2">::</font><font color="#030003" size="2"><font color="#030003" size="2">signal</font></font><font size="2">&lt; </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">void</font></font><font size="2"> ( </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">void</font></font><font size="2"> ) &gt; </font><font color="#030003" size="2"><font color="#030003" size="2">boostSignal</font></font><font size="2">;
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">for</font></font><font size="2">( </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">unsigned</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">int</font></font><font size="2"> </font><font color="#030003" size="2"><font color="#030003" size="2">i</font></font><font size="2"> = 0; </font><font color="#030003" size="2"><font color="#030003" size="2">i</font></font><font size="2"> &lt; 1000; ++</font><font color="#030003" size="2"><font color="#030003" size="2">i</font></font><font size="2"> )
<p>{</p>
<p></p></font><font color="#030003" size="2"><font color="#030003" size="2">manualSignal</font></font><font size="2">.</font><font color="#030003" size="2"><font color="#030003" size="2">push_back</font></font><font size="2">( &amp;</font><font color="#030003" size="2"><font color="#030003" size="2">foo</font></font><font size="2"> );
<p></p></font><font color="#030003" size="2"><font color="#030003" size="2">boostSignal</font></font><font size="2">.</font><font color="#030003" size="2"><font color="#030003" size="2">connect</font></font><font size="2">( &amp;</font><font color="#030003" size="2"><font color="#030003" size="2">foo</font></font><font size="2"> );
<p>}</p>
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">double</font></font><font size="2"> </font><font color="#030003" size="2"><font color="#030003" size="2">now</font></font><font size="2"> = </font><font color="#030003" size="2"><font color="#030003" size="2">tim</font></font><font size="2">.</font><font color="#030003" size="2"><font color="#030003" size="2">GetTimeInMS</font></font><font size="2">();
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">for</font></font><font size="2">( </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">unsigned</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">int</font></font><font size="2"> </font><font color="#030003" size="2"><font color="#030003" size="2">i</font></font><font size="2"> = 0; </font><font color="#030003" size="2"><font color="#030003" size="2">i</font></font><font size="2"> &lt; 1000; ++</font><font color="#030003" size="2"><font color="#030003" size="2">i</font></font><font size="2"> )
<p>{</p>
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">for</font></font><font size="2">( </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">unsigned</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">int</font></font><font size="2"> </font><font color="#030003" size="2"><font color="#030003" size="2">j</font></font><font size="2"> = 0; </font><font color="#030003" size="2"><font color="#030003" size="2">j</font></font><font size="2"> &lt; 1000; ++</font><font color="#030003" size="2"><font color="#030003" size="2">j</font></font><font size="2"> )
<p></p></font><font color="#030003" size="2"><font color="#030003" size="2">manualSignal</font></font><font size="2">[ </font><font color="#030003" size="2"><font color="#030003" size="2">i</font></font><font size="2"> ]( );
<p>}</p>
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">double</font></font><font size="2"> </font><font color="#030003" size="2"><font color="#030003" size="2">diff</font></font><font size="2"> = </font><font color="#030003" size="2"><font color="#030003" size="2">tim</font></font><font size="2">.</font><font color="#030003" size="2"><font color="#030003" size="2">GetTimeInMS</font></font><font size="2">() - </font><font color="#030003" size="2"><font color="#030003" size="2">now</font></font><font size="2">;
<p></p></font><font color="#030003" size="2"><font color="#030003" size="2">std</font></font><font size="2">::</font><font color="#030003" size="2"><font color="#030003" size="2">cout</font></font><font size="2"> &lt;&lt; </font><font color="#a31515" size="2"><font color="#a31515" size="2">&quot;took &quot;</font></font><font size="2"> &lt;&lt; </font><font color="#030003" size="2"><font color="#030003" size="2">diff</font></font><font size="2"> &lt;&lt; </font><font color="#a31515" size="2"><font color="#a31515" size="2">&quot; ms&quot;</font></font><font size="2"> &lt;&lt; </font><font color="#030003" size="2"><font color="#030003" size="2">std</font></font><font size="2">::</font><font color="#030003" size="2"><font color="#030003" size="2">endl</font></font><font size="2">;
<p></p></font><font color="#030003" size="2"><font color="#030003" size="2">now</font></font><font size="2"> = </font><font color="#030003" size="2"><font color="#030003" size="2">tim</font></font><font size="2">.</font><font color="#030003" size="2"><font color="#030003" size="2">GetTimeInMS</font></font><font size="2">();
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">for</font></font><font size="2">( </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">unsigned</font></font><font size="2"> </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">int</font></font><font size="2"> </font><font color="#030003" size="2"><font color="#030003" size="2">i</font></font><font size="2"> = 0; </font><font color="#030003" size="2"><font color="#030003" size="2">i</font></font><font size="2"> &lt; 1000; ++</font><font color="#030003" size="2"><font color="#030003" size="2">i</font></font><font size="2"> )
<p>{</p>
<p></p></font><font color="#030003" size="2"><font color="#030003" size="2">boostSignal</font></font><font size="2">( );
<p>}</p>
<p></p></font><font color="#030003" size="2"><font color="#030003" size="2">diff</font></font><font size="2"> = </font><font color="#030003" size="2"><font color="#030003" size="2">tim</font></font><font size="2">.</font><font color="#030003" size="2"><font color="#030003" size="2">GetTimeInMS</font></font><font size="2">() - </font><font color="#030003" size="2"><font color="#030003" size="2">now</font></font><font size="2">;
<p></p></font><font color="#030003" size="2"><font color="#030003" size="2">std</font></font><font size="2">::</font><font color="#030003" size="2"><font color="#030003" size="2">cout</font></font><font size="2"> &lt;&lt; </font><font color="#a31515" size="2"><font color="#a31515" size="2">&quot;took &quot;</font></font><font size="2"> &lt;&lt; </font><font color="#030003" size="2"><font color="#030003" size="2">diff</font></font><font size="2"> &lt;&lt; </font><font color="#a31515" size="2"><font color="#a31515" size="2">&quot; ms&quot;</font></font><font size="2"> &lt;&lt; </font><font color="#030003" size="2"><font color="#030003" size="2">std</font></font><font size="2">::</font><font color="#030003" size="2"><font color="#030003" size="2">endl</font></font><font size="2">;
<p>}</p></font></div>
<div>Which gives me the results ~5.2 ms for the vector variant and ~411 ms for the boost::signals variant. However, disabling checked iterators gives me ~3.8 ms for the vector variant and ~180 ms�for boost::signals, so it seems to make a world of difference for the overhead associated with slots.</div>

<div>�</div>
<div>We have more real world like scenario with our code base in which boost::signals seems to perform even worse, can&#39;t provide the entire code base however. I&#39;d think this has to do with the fact that the slots becomes more fragmented in memory due to the underlying container when used in the wild. That&#39;s merely speculation however.</div>
</div>