Skip to content

Instantly share code, notes, and snippets.

@joshbuddy
Forked from carllerche/gist:177377
Created August 29, 2009 04:12
Show Gist options
  • Save joshbuddy/177382 to your computer and use it in GitHub Desktop.
Save joshbuddy/177382 to your computer and use it in GitHub Desktop.
require "rubygems"
require "rbench"
def omg_slow
Array['one', 'two', 'three']
end
def omg_fast
['one', 'two', 'three']
end
RBench.run(10_000_000) do
column :one, :title => "Using explicit array decl"
column :two, :title => "Using implicit array decl"
report "Array creation" do
one { omg_slow }
two { omg_fast }
end
end
Using explicity array decl | Using implicit array decl |
---------------------------------------------------------------------------------------
Array creation 18.628 | 17.832 |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment