Boost logo

Boost :

From: Søren Lassen (s.lassen_at_[hidden])
Date: 2005-04-28 18:51:45


On Thu, 28 Apr 2005 20:55:02 +0200, Daniel Frey <d.frey_at_[hidden]> wrote:

> BTW, did you read Scott's errata?

No, I did not. But I now tested the two versions of operators.hpp with a
couple of compilers (Microsoft and Borland, that's what I have got up and
running at the moment, I think both are non-NRVO), and you are right: your
version is 10-20% faster (checked with a wristwatch) for operations on an
object containing 11 (I programmed first and counted afterwards, therefore
the odd number) 32-bit integers (see object definition below).

I have to admit that you are right, and I probably ought to hate that
fact. I do not, though, as I would rather live in peace with my fellow
human beings in general, and the Boost guys in particular.

Sorry, I should probably have intialized the dialogue in a more toned-down
manner. On the other hand, I do not feel that the somewhat heated tone of
the discussion is all my fault. E.g. when Dave tells me that there are no
programming guidelines on the homepage, I did feel sort of snubbed - he,
of all persons, should know that the homepage has a link to a set of
programming guidelines which at least appears to be official Boost policy.

Anyway, it may be a good idea to include e.g. a reference to Scott's
errata, and to the other books mentioned during the discussion on the
guidelines page. Likewise, when there is a discussion about e.g. the
const-ness of return values, it may be worth the effort to condense some
of the points into a simple text that gets a link on the Guidelines page.

-- 
Søren
P.S.: Here is my test program. My version of operators.hpp takes about 18  
seconds with the Borland compiler and 23 with the Microsoft compiler,  
whereas the official version takes about 15, resp. 20 seconds to run, all  
very approximately (no need to count the milliseconds, the assembly output  
also contains more "mov" instructions in my version):
#include <boost/operators.hpp>
class rvo:boost::addable1<rvo>{
       int a,b,c,d,e,f,g,h,i,j,k;
    public:
       rvo(int x=0){a=b=c=d=e=f=g=h=i=j=k=x;}
       rvo& operator+=(const rvo &r){
          a+=r.a;
          b+=r.b;
          c+=r.c;
          d+=r.d;
          e+=r.e;
          f+=r.f;
          g+=r.g;
          h+=r.h;
          i+=r.i;
          j+=r.j;
          k+=r.k;
          return *this;}
    };
int main(){
{
rvo a(1),b(2),d(4),e(5),c;
for(int i=0;i<100000000;++i) c=a+b+d+e;
}

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