Boost logo

Boost Users :

Subject: Re: [Boost-users] large variant performance compared (50 elements)
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2011-01-07 19:23:07


AMDG

On 1/7/2011 2:45 PM, Paul wrote:
> In a project we are using variants holding shared_ptr's. These
> variants are typically 20 items large but are growing as the project
> progresses. Now it seems that each time we add elements, we fall into
> issue's regarding excessive compilation time, huge pdb file or out of
> heap space errors on the compiler or linker.
>
> I took some time to compare various approaches using variants, here
> are the results:

Thank you for doing this.

> class C1 { public: int i; };
>
> Is there any way to explain these (huge) differences and what is
> preffered?
> - Why does the use of assignment operator have such a hugh impact?

I wouldn't have expected so much of a difference,
but the dispatching of the assignment operator is
relatively complex compared to the copy constructor
and apply_visitor, to handle exception safety.
You might check what happens if you add boost::blank
to the variant.

> - Why the difference between using shared_ptr or not?

It's probably because C1, C2, ... are all POD.
What happens if you add a destructor?

> - When to use the numbered variant or boost::variant<...>?

It shouldn't make a significant difference.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net