This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
ptr vs ref performance?
- To: "libstdc++ at sources dot redhat dot com" <libstdc++ at sources dot redhat dot com>
- Subject: ptr vs ref performance?
- From: Rob Willis <rob at e-critical dot com>
- Date: Thu, 14 Dec 2000 16:37:48 -0800
- Organization: eCritical
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