Sha256: 8caa6890a54c0bf15dad6e4e5eb6c501507af3033a11825c6f780c21531d959c

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

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}"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neo4j-wrapper-0.0.1-java lib/test.rb