Boost logo

Boost :

Subject: Re: [boost] [GSOC] Mentors for a C++11 TMP-related project
From: Louis Dionne (ldionne.2_at_[hidden])
Date: 2014-03-09 18:41:19


Larry Evans <cppljevans <at> suddenlink.net> writes:

> Do you have the results of the benchmark:
>
> https://github.com/ldionne/mpl11/blob/master/benchmark/foldl.rb

First, I would like to say that you should not draw conclusions from the
benchmarks at this time: the current foldl implementation for MPL11 lists
is not optimized at all. Also, I don't expect huge performance gains with
foldl; we can't do _much_ better than the MPL here since each step depends
on the previous one and so there's very little room for magic. There are
larger gains with other metafunctions, but I'm not going into the details
at this time.

So, here is a benchmark where the same headers are included for all tryouts.
What I mean is that we always include the headers necessary for mpl::vector,
mpl11::list and so on. This is in order to reduce the difference due to
including different headers.

http://imgur.com/rz4PZjo

As you can see, there is almost no difference. However, you can expect the
MPL11 to be as good as the best on the graph since I will just use that
implementation instead of the naive one when I'm ready to optimize.

Here is a benchmark where each tryout only includes the headers it uses.
This is the performance gain you would _actually_ get if you used one
implementation over another in your code.

http://imgur.com/uTIHi9D

Again, don't forget that benchmarks should be taken lightly at this stage.

> One problem with template metaprograms is the large compile times.
> The boost preprocessing library was used to alleviate this problem.
> The foldl.rb benchmark, IIUC, compares various techniques, including
> the existing boost::mpl technique. I sure others would be interested
> in seeing this comparison.

This is part of my material for C++Now 2014! Don't spoil attendance rates! :)

> BTW, one template metafunction class in that benchmark was the until
> template. I'd consider adding this to the library. OTOH, the while_
> metafunction here:

Thank you for the suggestion. In the MPL11, `while_` can
be implemented as (untested!):

    template <typename pred, typename f, typename state>
    using while_range = take_while<pred, iterate<f, state>>;

    template <typename pred, typename f, typename state>
    using while_ = last<while_range<pred, f, state>>;

I will consider adding something similar to the library.

Thanks for your interest in the project!

Louis Dionne


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk