[LRUG] Fwd: Recommendations for Ruby & Rails optimisation resources

Jonathon Horsman jonathon at arctickiwi.com
Mon Nov 26 07:36:58 PST 2012


>
> 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 ->*


Also Paperclip was generating an image URL for each row:

*= image_tag(country.flag.url(:normal), :alt => country.name, :title =>
country.name)*

By caching this in a hash (since there's only 8 different flags) seems to
provide a significant speed up.

Thanks for all the suggestions, I'm continuing with the profiling and have
already had a ~1sec speed improvement.

-- 
Jonathon Horsman
Director
Arctic Kiwi
Mobile: 079 42366038
Web: http://www.arctickiwi.com
Twitter: @jhorsman <http://www.twitter.com/jhorsman>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20121126/d9330479/attachment.html>


More information about the Chat mailing list