n8 / multi_fetch_fragments

Multi-fetch Fragments makes rendering and caching a collection of template partials easier and faster.
http://ninjasandrobots.com/rails-faster-partial-rendering-and-caching
MIT License
539 stars 63 forks source link

Significant speed increase for large collections #15

Closed yoricksijsling closed 11 years ago

yoricksijsling commented 11 years ago

This little loop was causing performance issues for me.

For a collection of 1517 items. With an empty cache, render time was about 1800ms. When the cache was filled, render time was 4000ms! With this change, i brought it down to less than 40ms.

I suspect that the .delete call is the cause of this. The searching and removing of the element is both O(n). This issue might also have been solved by using a Set for the collection, but i haven't tried that.

n8 commented 11 years ago

Sorry I've been slacking on this. Life has overloaded me with other support requests :) I'm looking at these pull requests now.

yoricksijsling commented 11 years ago

Thanks @n8 ! Now I can switch to your version of the gem again :+1: