ptr vs ref performance??
Rob Willis
rob@e-critical.com
Thu Dec 14 16:33:00 GMT 2000
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
More information about the Gcc
mailing list