> I was under the impression that while Symbol#to_proc was cool, it was
> really
> way slower than using the standard Ruby way.
>
> That might really affect something like:
>
> User.find(:all).map &its.contacts.map(&its.last_name.capitalize)
>
> If I remember correctly I saw some crazy benchmarks showing that using
> Symbol#to_proc was like 5 times slower.
>
> Anyone knows what I'm talking about and has more info about performance
> issues related to this Symbol#to_proc?

Yes, it is slow just like Symbol#to_proc. One of the comments lists these
benchmark results:

>> Benchmark.bm do |b|
?>   b.report('normal') { n.times { (1..100).select { |i| i.size } } }
>>   b.report('method') { n.times { (1..100).select &it.size } }
>>   b.report('toproc') { n.times { (1..100).select(&:size)  }  }
>> end
      user     system      total        real
normal  0.090000   0.000000   0.090000 (  0.093936)
method  0.490000   0.000000   0.490000 (  0.499792)
toproc  0.460000   0.000000   0.460000 (  0.474050)


>
> -Matt
>
>
> --
> blog: http://railsontherun.com
>
> On 8/20/07, Brian Chapados <[EMAIL PROTECTED]> wrote:
>>
>> http://jicksta.com/articles/2007/08/04/the-methodphitamine
>>
>> I finally finished reading through my pile-o-feeds. It's a few weeks
>> old,
>> but if you haven't seen it already, this one is awesome!
>>
>> spoiler:
>> User.find(:all).map &its.contacts.map(&its.last_name.capitalize)
>>
>> Brian
>>
>> _______________________________________________
>> Sdruby mailing list
>> [email protected]
>> http://lists.sdruby.com/mailman/listinfo/sdruby
>>
> _______________________________________________
> Sdruby mailing list
> [email protected]
> http://lists.sdruby.com/mailman/listinfo/sdruby
>


_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to