Thanks for your feedback.
Yes, I will need find places where args passes to Array() is not kind of Array 
class.

пятница, 6 мая 2016 г., 1:02:26 UTC+3 пользователь Ufuk Kayserilioglu 
написал:
>
> Andrey,
>
> Be careful with this because the sematics of the two are not exactly equal:
>
> [1] pry(main)> Array([123])
> => [123]
> [2] pry(main)> [[123]]
> => [[123]]
>
>
> and the desired sematics in the locations that you link to seem to be the 
> Array() variant where the input might be a scalar or an array itself.
>
> --
> Ufuk Kayserilioglu
>
>
> On 6 May 2016 at 00:29:29, Andrey Molchanov (neo...@gmail.com 
> <javascript:>) wrote:
> Hi all, 
> In some 
> <https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/preloader/association.rb#L126>
>  places 
> <https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/preloader/association.rb#L154>
>  new 
> array creates as a Array(). If we replace it to a [], we increase 
> performance about 1.7 times:
>
>
> def old_slow
>    Array(123)
> end
>
> def new_fast
>    [123]
> end
>
>
> Benchmark.ips do |x|
>   x.report("new_fast") { new_fast }
>   x.report("old_slow") { old_slow }
>   x.compare!
> end
>
> Calculating -------------------------------------
>             new_fast   184.920k i/100ms
>             old_slow   150.931k i/100ms
> -------------------------------------------------
>             new_fast      7.528M (± 4.4%) i/s -     37.724M
>             old_slow      4.408M (± 4.3%) i/s -     22.036M
>
> Comparison:
>             new_fast:  7528299.2 i/s
>             old_slow:  4408283.1 i/s - 1.71x slower
>
>
> What do you think about it?
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-co...@googlegroups.com <javascript:>.
> To post to this group, send email to rubyonra...@googlegroups.com 
> <javascript:>.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to