Boost logo

Boost :

Subject: Re: [boost] [Block Pointer] Up to 600% faster than Shared Pointer
From: Phil Bouchard (philippeb8_at_[hidden])
Date: 2016-03-12 22:12:05


On 03/12/2016 09:22 PM, Glen Fernandes wrote:
> On Sat, Mar 12, 2016 at 9:08 PM, Phil Bouchard <philippeb8_at_[hidden]> wrote:
>>
>> Also block_ptr<> is now distinct from the allocator used.
>>
>> Finally the class fastblock<> is properly abstracted and it is easy to add
>> user defined block types just like this one:
>>
>> template <typename T>
>> class fastblock : public block<T, fast_pool_allocator<T> >
>
> Hi Phil,
>
> To add to our earlier discussion, you should also include the
> benchmark for allocate_shared() with fast_pool_allocator.
>
> 1. shared_ptr (new)
> 2. shared_ptr (make_shared)
> 3. shared_ptr (allocate_shared with fast_pool_allocator)
> 4. block_ptr
> 5. block_ptr (fastblock)
> 6. unique_ptr/auto_ptr (new/make_unique)

Good point, I was not aware it could be used this way. I just added
fast_pool_allocator<>() to the benchmark so now the comparison is fair
and block_ptr<> still is faster by 125%:

make:
auto_ptr: 27539691 ns
shared_ptr: 31368593 ns

alloc:
shared_ptr: 10995612 ns <-

new:
auto_ptr: 22648835 ns
shared_ptr: 48179069 ns
block_ptr: 8775982 ns <-

Not to mention the code is more elegant using operator new.

-Phil


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