Boost logo

Boost Users :

From: Klaus Nowikow (nowikow_at_[hidden])
Date: 2004-07-01 09:48:30


Peter Dimov wrote:

> Klaus Nowikow wrote:
> >
> > I changed the test program (see below). Now I use object_pool<>
> > to create and destroy a number of elements (I use a vector<C*> to
> > store them in the meantime). The results are even worse than before:
> >
> > new/delete: 0.08s
> > object_pool: 25.20s
>
> [...]
>
> > template <template <class, class> class Pool>
> > double Test()
> > {
> > Pool<C> P(CHUNK_SIZE);
> > boost::timer Timer;
> >
> > std::vector<C*> V;
> > for(int i = 0; i < NUM_ELEMENTS; ++i)
> > {
> > V.push_back(P.construct());
> > }
> > for(std::vector<C*>::iterator pos = V.begin(), end = V.end(); pos !=
> > end; ++pos) {
> > P.destroy(*pos);
> > }
> >
> > return Timer.elapsed();
> > }
>
> Your test is still very unrealistic. You create a large
> number of objects in
> one batch, then destroy them afterwards. A more realistic
> scenario would
> have creation and destruction interleaved.
>
> The most accurate test would be to try Boost.Pool with your actual
> application and see how it affects its real-world
> performance. It's still
> possible for it to be slower, of course, but at least you'd
> measure the real
> thing.

Of course you're right. Obviously I broke the "don't optimize what does
not have to be optimized" rule ;-).
When creating and deleting 100000 Objects with new/delete takes only
0.1 seconds I won't have to look for something more efficient.
I will do what you suggest: write my code and see if it needs
optimization.

Regards,

Klaus


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