Skip to content

Instantly share code, notes, and snippets.

@jnstq
Created May 28, 2009 12:43
Show Gist options
  • Save jnstq/119270 to your computer and use it in GitHub Desktop.
Save jnstq/119270 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'rbench'
require 'activesupport'
strings = %w(jon stefan carl sofie)
numbers = [1, 3, 5, 7]
RBench.run(10_000) do
column :one
column :two
report "map with block" do
one { strings.map {|s| s.length } }
two { numbers.map {|i| i.to_s } }
end
report "map with symbol to proc" do
one { strings.map(&:length) }
two { numbers.map(&:to_s) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment