HAML can be extremely slow compared to ERB, particularly when you have elements with multiple attributes (due to how it's careful to encode things properly).<div><br></div><div>At Zopa we had an extreme case of a select list where we were generating hundreds of options with a few data attributes. For that section we used the literal syntax and only escaped the values/attributes that could be potentially dangerous. Something like this: <a href="https://gist.github.com/4148888">https://gist.github.com/4148888</a></div>
<div><br></div><div>After making that change the rendering went down to sub-second from 4-5 seconds if memory serves. It might be worth trying out if your markup is within a loop and has a reasonable number of attributes. We didn't go as far as converting the whole page to ERB as using that trick in that one place was sufficient to get acceptable rendering speed.<br>
</div><div><br></div><div><br></div><div><br></div><div class="gmail_extra"><br clear="all"><b>Garry Shutler</b><div><br><div><a href="http://twitter.com/gshutler" target="_blank">@gshutler</a></div><div><a href="http://evenitron.com" target="_blank">evenitron.com</a><br>
<a href="http://www.robustsoftware.co.uk" target="_blank">www.robustsoftware.co.uk</a></div></div><br>
<br><br><div class="gmail_quote">On 26 November 2012 15:36, Jonathon Horsman <span dir="ltr"><<a href="mailto:jonathon@arctickiwi.com" target="_blank">jonathon@arctickiwi.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_extra"><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Are you rendering a lot of partials? There's quite a bit of overhead<br>
in setting up each partial, it can sometimes be worth flattening them<br>
out.<br></blockquote><div><br></div></div><div>This is an interesting one, I thought this too but timing before and after flattening shows that rendering partials is actually faster.</div><div><br></div><div>So I have</div>
<div>
<br></div><div><i>= render :partial => "share", :collection => @shares</i></div><div><br></div><div>renders about 500ms faster than this:</div><div><br></div><div><i>- @shares.each do |share|</i></div><div>
<i> <!-- inline row HAML -></i></div></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div>Also Paperclip was generating an image URL for each row:</div><div class="gmail_extra"><br></div><div class="gmail_extra">
<i>= image_tag(country.flag.url(:normal), :alt => <a href="http://country.name" target="_blank">country.name</a>, :title => <a href="http://country.name" target="_blank">country.name</a>)</i><br><br clear="all"><div>
By caching this in a hash (since there's only 8 different flags) seems to provide a significant speed up.</div>
<div><br></div><div>Thanks for all the suggestions, I'm continuing with the profiling and have already had a ~1sec speed improvement.</div><div class="im"><div><br></div>-- <br>Jonathon Horsman<br>Director<div>Arctic Kiwi<br>
Mobile: 079 42366038<br>
Web: <a style="color:rgb(0,153,0)" href="http://www.arctickiwi.com" target="_blank">http://www.arctickiwi.com</a><div>Twitter: <a style="color:rgb(0,153,0)" href="http://www.twitter.com/jhorsman" target="_blank">@jhorsman</a><br>
<img><br></div></div><br>
</div></div>
<br>_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
<br></blockquote></div><br></div>