Boost logo

Boost :

From: Vincent Finn (vincent_finn_at_[hidden])
Date: 2002-10-08 08:27:32


Thorsten Ottosen wrote:
> ----- Original Message -----
> From: "Vincent Finn" <vincent_finn_at_[hidden]>
>
>>Have you done any time tests to see what the speed is like ?
>
> not yet. a quick comparison between
>
> #include "init.hpp"
>
> int main()
> {
> std::vector<int> v;
> init::set_cont( v ) = 1,2,3,4,5;
> }
>
> and
>
> #include "vector"
>
> int main()
> {
> std::vector<int> v;
> v.push_back( 1 );
> v.push_back( 2 );
> v.push_back( 3 );
> v.push_back( 4 );
> v.push_back( 5 );
> }
>
> gives the same execuatble for Comeau 4.3. Gcc 2.95.3-10 is somewhat poor
> compared. Not even -O2 can give the same binary size.
> To be sure one would need to test all compilers. I suspect that gcc have
> improved a lot since 2.95.10?

I did some tests on VC6 and it is a little poor too
set_cont is 5% slower than push back for constants
and about 2.5% slower for variables

Still that is fast enough for most cases I would ever need :-)

It is a nice advantage over C initialisation that you can go
init::set_cont( v ) = i,j,k
I'm not sure how useful that is but no harm having it

>>Is there much of a hit by comparison to the uglier versions ??
>
> Are you refereing to the enum stuff?

No. I meant the repeated use of push_back()
It's a bit ugly :->

I didn't look too closely at the enum functions
I rarely have need of that style of initialisation

I have one suggestion though
is it possible to take the functions used as an argument of some sort
i.e. use push_op() in the class and this would be push() or push_back()
etc as appropriate !
A vector\deque\list version could be typedef'd
as could a map version etc...

The reason I ask is that VC doesn't have hash_map, slist etc...
and it also doesn't accept the template specialisation used
so I had to dump all code other than the default\vector version !

        Vin


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