At 09:17 AM 12/15/2004, Caleb Epstein wrote:
On Mon, 13 Dec 2004 09:01:01 -0800, Frank Maddin
wrote:
We've been thinking about using certain boost functionality on a project.
We were trying to keep the number of allocations down.
See the attached test program which makes the Hello class "noisy" and runs two different versions of your signals test. One uses object copy semantics and the other uses reference semantics. Compare the output:
copy test: Hello::Hello () @ 0xbfffb950 Hello::Hello (const ref) @ 0xbfffb8c0 Hello::Hello (const ref) @ 0xbfffb870 Hello::Hello (const ref) @ 0xbfffb830 Hello::Hello (const ref) @ 0xbfffb7e0 Hello::Hello (const ref) @ 0x8050fb0 Hello::~Hello @ 0xbfffb7e0 Hello::~Hello @ 0xbfffb830 Hello::~Hello @ 0xbfffb870 Hello::~Hello @ 0xbfffb8c0 Hello::Hello (const ref) @ 0x8050fc0 Hello::Hello (const ref) @ 0x8050fc8 Hello::Hello (const ref) @ 0x8050fd0 Hello::~Hello @ 0x8050fc8 Hello::~Hello @ 0x8050fc0 Hello::~Hello @ 0x8050fb0 i = 1968 Hello::~Hello @ 0x8050fd0 Hello::~Hello @ 0xbfffb950
ref test: Hello::Hello () @ 0xbfffb950 i = 1968 Hello::~Hello @ 0xbfffb950
Wow! That is a pretty substantial difference. Seems like the signals docs should make a point of explaining the efficiency gained by using ref. Or maybe they do, but I didn't find anything in several minutes of poking around the docs. There is no table of contents entry like "Efficiency considerations" or similar. --Beman