Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require "rubygems"
require "rbench"
def omg_slow
return 1
end
def omg_fast
1
end
RBench.run(10_000_000) do
column :one, :title => "Using return"
column :two, :title => "Avoiding return"
report "Returning from methods" do
one { omg_slow }
two { omg_fast }
end
end
__END__
Using return | Avoiding return |
---------------------------------------------------------------
Returning from methods 3.991 | 2.502 |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.