Created
October 13, 2010 13:55
-
-
Save chad/624069 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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