Skip to content

Instantly share code, notes, and snippets.

@chrisseaton
Created April 30, 2015 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisseaton/7ead01c76ba04e0b987f to your computer and use it in GitHub Desktop.
Save chrisseaton/7ead01c76ba04e0b987f to your computer and use it in GitHub Desktop.
module Foo
extend self
def foo(a, b, c)
hash = {a: a, b: b, c: c}
array = hash.map { |k, v| v }
x = array[0]
y = [a, b, c].sort[1]
x + y
end
end
class Bar
def method_missing(method, *args)
if Foo.respond_to?(method)
Foo.send(method, *args)
else
0
end
end
end
bar = Bar.new
loop do
start = Time.now
1_000_000.times do
# This block should be compiled to the constant Fixnum value 22
bar.foo(14, 8, 6)
end
puts Time.now - start
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment