From: Robert Dober Date: 2008-05-23T01:42:51+09:00 Subject: Re: Prevent ruby constant variables from changing? On Thu, May 22, 2008 at 6:05 PM, ara.t.howard wrote: > > On May 22, 2008, at 9:39 AM, Robert Dober wrote: > >> c.module_eval creates faster code though... > > really? that's interesting. You are right I better recheck that ... ... indeed I was wrong, I just increased N from 10**5 to 10**6 and that equals out what must have been measurement fluctations caused by the extremely short runtime. The performance is equal. require 'benchmark' class A def a; 42 end end a = A.new B = Class::new B.module_eval do def a; 42 end end b = B.new N=100_000 Benchmark::bmbm do |bm| bm.report( "classic" ) do N.times do a.a end end bm.report( "meval" ) do N.times do b.a end end end R.