Speed this up a bit
&method looks more elegant (to me) but it's 3 times slower: ``` require 'benchmark/ips' ARRAY = ["test", 2, 3, 4] Benchmark.ips do |x| x.report('fast') { ARRAY.map { |r| parse_record(r) } } x.report('slow') { ARRAY.map &method(:parse_record) } x.compare! end ``` Comparison: fast: 1046992.2 i/s slow: 332722.5 i/s - 3.15x slower
This commit is contained in:
parent
bbae652fd0
commit
d19800b480
|
@ -50,7 +50,7 @@ module Ransack
|
|||
private
|
||||
|
||||
def options_for(record)
|
||||
record.map &method(:parse_record)
|
||||
record.map { |r| parse_record(r) }
|
||||
end
|
||||
|
||||
def parse_record(object)
|
||||
|
|
Loading…
Reference in New Issue