require "benchmark/ips" puts RUBY_DESCRIPTION class Inherit < Struct.new(:id, :name, :age) def name_and_age "#{name}, #{age}" end end Block = Struct.new(:id, :name, :age) do def name_and_age "#{name}, #{age}" end end Reopen = Struct.new(:id, :name, :age) class Reopen def name_and_age "#{name}, #{age}" end end Benchmark.ips do |x| x.report("Inherit"){ |times| i = 0 while i < times Inherit.new(1, 2, 3).name_and_age i += 1 end } x.report("Block"){ |times| i = 0 while i < times Block.new(1, 2, 3).name_and_age i += 1 end } x.report("Reopen"){ |times| i = 0 while i < times Reopen.new(1, 2, 3).name_and_age i += 1 end } x.compare! end