jnstq (owner)

Revisions

gist: 119270 Download_button fork
public
Public Clone URL: git://gist.github.com/119270.git
Embed All Files: show embed
snippet.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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