Skip to content

Instantly share code, notes, and snippets.

@actsasflinn
Forked from carllerche/gist:177377
Created August 29, 2009 04:25
Show Gist options
  • Save actsasflinn/177384 to your computer and use it in GitHub Desktop.
Save actsasflinn/177384 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