
On 4/5/2012 11:55 PM, Dave Abrahams wrote:
on Thu Apr 05 2012, Thomas Heller <thom.heller-AT-googlemail.com> wrote:
I, personally, haven't come around to actually extract meaningful benchmarks from, for example, phoenix. One thing that immediately comes to my mind is whether to deferr the instantation of a template as long as possible, or to have it instantiated immediately. Example:
template <typename T> struct meta_function1 { typedef T type; };
template <> struct meta_function1<int> { typedef int type; };
template <typename T, typename Dummy = void> struct meta_function2 { typedef T type; };
template <typename Dummy> struct meta_function2<int, Dummy> { typedef int type; };
The question now is: which is faster meta_function1 or meta_function2? Of course, in this case we won't get meaningful numbers. However, some claim that meta_function2 is generally faster, especially in the context of many full specializations.
That's a bit surprising.
In C++03 compilers, fully lazy evaluation seems to become expensive in surprising ways that aren't yet well-understood.
Thomas, Fusion is an easy target. If anyone would like to try this out --grep or write a script that converts Fusion's meta_function1 style to meta_function2 (lazy) style, please do so and show us the benchmark results (e.g. by running the Fusion test suite over either versions). Without such *real* numbers, it will remain a myth and we will never really know. I'd love to tweak Fusion if such a trick is found to really improve CT. Regards, -- Joel de Guzman http://www.boostpro.com http://boost-spirit.com