This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

ptr vs ref performance?



In the process of playing with the performance of "long long" types, i
noticed another oddity.  It appears as if using a reference variable is
faster than de-referencing from a pointer.  My assumption would of been
that the time for these operations would be exactly the same, but
obviously there is something more going on in ptr dereferences...

My performance (on P3/600, egcs-20000612 compiler, RH-6.2) for
completing 6 billion ops:

ptr de-ref:  13.23 secs
ref var      10.85 secs

Looks like ref variables are 18% faster ??  

The operations i used to test:

long value = 0;
long test  = 5213;

long & tr( test )
long * tp = &test;

ptr de-ref:
   value = *tp;

ref access;
   value = tr;

I substracted out the looping and assignment overheads in the
performance #'s above.  

Can anyone explain why this is?
-Rob

-- 
Rob Willis
rob@e-critical.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]