[LRUG] Fwd: Recommendations for Ruby & Rails optimisation resources
Jonathan del Strother
maillist at steelskies.com
Mon Nov 26 07:40:50 PST 2012
On 26 November 2012 15:36, Jonathon Horsman <jonathon at arctickiwi.com> wrote:
> Are you rendering a lot of partials? There's quite a bit of overhead
>> in setting up each partial, it can sometimes be worth flattening them
>> out.
>>
>
> This is an interesting one, I thought this too but timing before and after
> flattening shows that rendering partials is actually faster.
>
> So I have
>
> *= render :partial => "share", :collection => @shares*
>
> renders about 500ms faster than this:
>
> *- @shares.each do |share|*
> * <!-- inline row HAML ->*
>
Yep, using "render :collection" isn't actually too bad, since (IIRC) Rails
can prepare the partial once & reuse it. If you were to swap it for the
apparently identical -
- @shares.each do |share|
= render :partial=>"share", :object=>share
- then Rails does have to recompile each time, which can be pretty slow.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20121126/971dcdd5/attachment-0003.html>
More information about the Chat
mailing list