def calc(x) x + 1 end p = method(:calc) t = Time.now (0..10000).each { |x| calc(x) } total = Time.now - t puts "1. total = #{total}" #p = Proc.new {|x| x + 1} t = Time.now (0..10000).each { |x| p.call(x) } total = Time.now - t puts "2. total = #{total}" puts "=================" t = Time.now (0..10000).each { |x| calc(x) } total = Time.now - t puts "1. total = #{total}" t = Time.now (0..10000).each { |x| p.call(x) } total = Time.now - t puts "2. total = #{total}" puts "=================" t = Time.now (0..10000).each { |x| calc(x) } total = Time.now - t puts "1. total = #{total}" t = Time.now (0..10000).each { |x| p.call(x) } total = Time.now - t puts "2. total = #{total}" p = method(:calc).to_proc puts "================= TO PROC" t = Time.now (0..10000).each { |x| calc(x) } total = Time.now - t puts "1. total = #{total}" t = Time.now (0..10000).each { |x| p.call(x) } total = Time.now - t puts "2. total = #{total}" puts "================= TO PROC" t = Time.now (0..10000).each { |x| calc(x) } total = Time.now - t puts "1. total = #{total}" t = Time.now (0..10000).each { |x| p.call(x) } total = Time.now - t puts "2. total = #{total}"