From: Edoardo Rossi Date: 2013-04-03T17:12:59+09:00 Subject: Re: respond_to? vs include? On Wed, Apr 3, 2013 at 9:48 AM, Robert Klemme wrote: > > > > On Mon, Apr 1, 2013 at 8:26 AM, Edoardo Rossi wrote: >> >> On Mon, Apr 1, 2013 at 12:07 AM, Adam Prescott wrote: >> > Your benchmark looks okay. I added a comment to your Gist about a fork >> > I made that shows the O(n) behaviour of include? versus the >> > constant-time behaviour of respond_to? by just tweaking your code. > > > Yeah, Array lookup is O(n) - that's what one would expect. But the Array > creation has overhead as well. > >> Thank you so much Adam. >> Very interesting... appreciated. > > > I think the situation is more dramatic: for a single method test the > #instance_methods call needs to be included. > > https://gist.github.com/rklemme/5299235 > > Kind regards > > robert > > > -- > remember.guy do |as, often| as.you_can - without end > http://blog.rubybestpractices.com/ Considerably more dramatic! Thank you so much Robert for pointed that out... eddie.