Skip to content

Instantly share code, notes, and snippets.

@carllerche
Created August 29, 2009 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save carllerche/177377 to your computer and use it in GitHub Desktop.
Save carllerche/177377 to your computer and use it in GitHub Desktop.
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