Skip to content

@dbussink /gist:700a1d13d6ca8cf44469 secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
require 'benchmark/ips'
class Foo
define_method("foo") { }
class_eval 'def bar; end'
def inline_foo
foo
foo
foo
foo
foo
end
def inline_bar
bar
bar
bar
bar
bar
end
end
Benchmark.ips do |x|
foo = Foo.new
x.report("class_eval") { foo.inline_bar }
x.report("define_method") { foo.inline_foo }
end
class_eval 6801365.4 (±1.1%) i/s - 34000866 in 4.999752s (cycle=203598)
define_method 4382386.9 (±2.1%) i/s - 21982388 in 5.018583s (cycle=238939)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.