|
Boost : |
From: Greg Colvin (gcolvin_at_[hidden])
Date: 2000-01-28 23:45:39
From: <jsiek_at_[hidden]>
> I'd be willing to bet this new linked implementation is faster in most
> situations. Going to memory is getting slower and slower relative to
> clock speeds, and the extra copying just gives the cpu something to do
> instead of stalling :)
The copy code for the current implementation expands to this:
if (pn != rpn) {
if (--*pn == 0) { delete px; delete pn; }
px = rpx;
++*(pn = rpn);
}
The copy code for Mark's implementation expands to this:
lastref = !left && !right;
if (left || right)
{
if (left)
left->right = right;
if (right)
right->left = left;
right = left = 0;
}
if (lastref && ptr)
delete ptr;
ptr = pNewLeft->ptr;
left = pNewLeft;
right = pNewLeft->right;
pNewLeft->right = this;
if (right)
right->left = this;
> It would be interesting to see the performance difference in the
> pathological case of doing nothing but a bunch of ptr assignments in a
> tight loop.
Yes, it would. Mark?
> Greg Colvin writes:
> > A very interesting implementation. Its existence may be a good reason to
> > deprecate the use_count() member of shared_ptr. I'm not too sure that
> > you would see a 4X improvement in typical applications though, since your
> > test does a lot of allocation and very little copying. I'd be interested
> > in seeing the results of more thorough tests.
>
> ------------------------------------------------------------------------
> Want to send money instantly to anyone, anywhere, anytime?
> You can today at X.com - and we'll give you $20 to try it! Sign
> up today at X.com. It's quick, free, & there's no obligation!
> http://click.egroups.com/1/332/1/_/9351/_/949120014/
>
> -- 20 megs of disk space in your group's Document Vault
> -- http://www.egroups.com/docvault/boost/?m=1
>
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk