From: Brian Candler Date: 2007-05-31T16:23:25+09:00 Subject: Re: Does this benchmark make sense? On Thu, May 31, 2007 at 04:13:26PM +0900, Farhad Farzaneh wrote: > > "self" doesn't involve looking up a constant; "Klassname" does. > > Thanks - actually, I believe that the correct comparison is: > [self.x] > # user system total real > # direct 1.880000 0.010000 1.890000 ( 1.900675) > # send 2.460000 0.010000 2.470000 ( 2.509326) > # eval 11.440000 0.050000 11.490000 ( 11.688772) > > [Klassname.x] > # user system total real > # direct 2.230000 0.010000 2.240000 ( 2.313980) > # send 2.830000 0.020000 2.850000 ( 2.919039) > # eval 11.440000 0.050000 11.490000 ( 11.667510) OK, checking again: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/253666 So, "Klassname.t" and "self.class.t" are almost identical (where 'self' is an instance of Klassname), but "Klassname.t" is slower than "self.t" (where 'self' is Klassname). OK, it's a bit odd :-)