mrubyのbenchmarkディレクトリにao-render.rb(AOベンチ)があるわけだが、このコードを見ると例えばVevtorクラスのgetter/setterは自前で定義されている。作った人(@miura1729さん)によると元はytl用のものでattr系メソッドが無かったからということなのだが、これをattr系で定義したら速くなるのだろうか。 Ruby1.9.3では速くなる。 require 'benchmark' class Foo def hoge @hoge end def hoge=(v) @hoge = v end end class Bar attr_accessor :fuga end Benchmark.bm do |bm| bm.report("Foo#hoge") do a = Foo.new 1000000.times do a.hoge = a.hoge