Skip to content

Instantly share code, notes, and snippets.

@chad
Created October 13, 2010 13:55
Show Gist options
  • Save chad/624069 to your computer and use it in GitHub Desktop.
Save chad/624069 to your computer and use it in GitHub Desktop.
require 'benchmark'
class Chad
def a_method
1
end
end
c = Chad.new
Benchmark.bmbm do |bm|
bm.report("send") {100000.times{ c.send(:a_method)}}
bm.report("eval") {100000.times{ eval("c.a_method")}}
end
__END__
Rehearsal ----------------------------------------
send 0.020000 0.000000 0.020000 ( 0.013512)
eval 0.790000 0.000000 0.790000 ( 0.793697)
------------------------------- total: 0.810000sec
user system total real
send 0.010000 0.000000 0.010000 ( 0.013617)
eval 0.800000 0.000000 0.800000 ( 0.790621)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment