|
Boost : |
From: Greg Colvin (gcolvin_at_[hidden])
Date: 2000-01-29 13:39:28
From: Gavin Collings <gcollings_at_[hidden]>
> I've already done these tests since my implementation uses a circular list
> anyway. I've attached the implementation, the test code and a spreadsheet I
> used to fit the results. (assignment boils down to what you have with a
> minor mod to bypass unlinking code if you're not attached). I ran these
> tests on Visual C++ 6 SP3 in Release mode. It may be useful to try some
> other compilers.
Could you send us the results in some non-proprietary format -- I don't have
Excel and don't want to buy it.
> In summary, sharing operations i.e. assignment / copy-cons run at about half
> the speed of their shared_ptr counterparts. The real advantage comes from
> avoiding the huge overhead of the heap allocation for the reference count in
> shared_ptr. This worked out at about 2.9 microseconds for shared_ptr and
> was indistinguishable from zero for linked_ptr.
And the microseconds per copy was what?
> Taking all of this into consideration, shared_ptr becomes more efficient at
> above about 50 sharing operations - well beyond common usage I should
> imagine.
Thanks for running these tests. If you have a chance could you try the
following?
#include <boost/smart_ptr.h>
using namespace std;
using namespace boost;
main(int argc, char** argv) {
typedef counted_ptr<int> ptr_int;
const int N = atoi(argv[1]);
{ clock_t start = clock();
vector<ptr_int> container;
for (int i = 0; i < N; i++ )
container.push_back(ptr_int(new int(rand())));
printf("%ld\n",(long)clock() - start);
sort(container.begin(), container.end());
printf("%ld\n",(long)clock() - start);
}
{ clock_t start = clock();
list<ptr_int> container;
for (int i = 0; i < N; i++ )
container.push_back(ptr_int(new int(rand())));
printf("%ld\n",(long)clock() - start);
container.sort();
printf("%ld\n",(long)clock() - start);
}
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk