Sheldon Project

Rendering Optimization









me@somewhere.com
June 6th 2013

O(n2)


  @elements.each do |element|
    ...
    @elements.select{...}.each do |child|
      ...
    end
  end
            

Hash It!

O(n)


  @element_hash.each do |parent, children|
    ...
  end
            

70%↗

Slow Iteration?


  @elements.each do |element|
    render :partial => "..."
  end
            

Use Collection


  render :partial => "...", :collection => @elements
            

20%↗

Fact!

link_to is 3 times slower than raw url



Replace 'em!

40%↗

Performance Comparison

In total,

86%↗

Ajax Call

with loading spinner

Learned

  • Ruby, Rails, logger
  • Javascript, JQuery

Special Thanks

my mentor and everyone in my team