Skip to content

Instantly share code, notes, and snippets.

@dmitryrck
Created May 19, 2012 01:55
Show Gist options
  • Save dmitryrck/2728564 to your computer and use it in GitHub Desktop.
Save dmitryrck/2728564 to your computer and use it in GitHub Desktop.
# run ./beck.rb
require 'benchmark'
arr = []
10_000_000.times do |t|
arr.push t
end
DEFAULT = 10_000_000
Benchmark.bm do |x|
x.report 'usando map----' do
DEFAULT.times do |num|
arr.method(:map)
end
end
x.report 'usando collect' do
DEFAULT.times do |num|
arr.method(:collect)
end
end
end
% ruby ./beck.rb
user system total real
usando map---- 9.800000 0.270000 10.070000 ( 10.082111)
usando collect 16.710000 0.030000 16.740000 ( 16.744178)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment