On 10/20/07, Bill Dortch <[EMAIL PROTECTED]> wrote:
Might it have something to do with the reference to self in the call?
This appears to be at least part of the story. If I change:
def benchmark_attr_get
...
a; a; a; ...
...
end
to:
def benchmark_attr_get
...
self.a; self.a; self.a; ...
...
end
then the access time nearly doubles:
100k * 100 attr gets (a;), 1 ivar 2.703000 0.000000 2.703000 (
2.703000)
100k * 100 attr gets (self.a;), 1 ivar 5.234000 0.000000 5.234000 (
5.234000)
Even stranger, the self. reference is slower than accessing an attr in a
separate object (x):
100k * 100 attr gets (x.a;), 1 ivar 3.922000 0.000000 3.922000 (
3.922000)
Curious, no?
-Bill