Re: [Boost-users] Performance optimization in Boost using std::vector<>
Hi, not sure if the OP needs std::vector but... I'd recommend boost::container::vector which has a dedicated constructor [1] and resize() [2] method tagged with default_init_t argument, both of which default initialize the values in the vector. For primitives it basically means it leaves them uninitialized, hence there's no overhead when the vector is to be filled with real data soon. WBR, Adam Romanek
Hi Adam As following your point, the benefit of boost::container::vector supported the "default_init_t" method so that it 's quite convince and safety comparing with std::vector<> is that right ? are there additional advantages ? Hi Ilja You said "Boost::mpi version is always at least 10 times slower. " make me confused, I guess it's should be a typo, isn't ? Martin
Hi
You said "Boost::mpi version is always at least 10 times slower. " make me confused, I guess it's should be a typo, isn't ?
No it shouldn't, according to the test I posted creating and sending a vector with 10^6 doubles takes about 0.02 s using MPI and 0.3 s using boost::mpi. Ilja
On 22.02.2015 08:17, chmhou@sina.com wrote:
Hi, not sure if the OP needs std::vector but... I'd recommend boost::container::vector which has a dedicated constructor [1] and resize() [2] method tagged with default_init_t argument, both of which default initialize the values in the vector. For primitives it basically means it leaves them uninitialized, hence there's no overhead when the vector is to be filled with real data soon. WBR, Adam Romanek
Hi Adam As following your point, the benefit of boost::container::vector supported the "default_init_t" method so that it 's quite convince and safety comparing with std::vector<> is that right ? are there additional advantages ?
Not sure what convenience and safety you refer to. To me both of these aspects are exactly the same for both containers. The difference is that boost::container::vector with "default_init_t" uses *default initialization* and std::vector uses *value initialization* to initialize the data they hold. The difference has huge impact on performance as default initialization for primitive types is a no-op. WBR, Adam Romanek
participants (3)
-
Adam Romanek
-
chmhou@sina.com
-
Ilja Honkonen