Created
April 9, 2010 18:21
-
-
Save tal/361430 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'benchmark' | |
| Benchmark.bmbm do |x| | |
| x.report 'each_with_index' do | |
| i = [] | |
| [*1..1000].each_with_index do |item, index| | |
| i << item*index | |
| end | |
| end | |
| x.report 'enum_for collect with_index' do | |
| [*1..1000].enum_for(:collect).with_index do |item,index| | |
| item*index | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment