# Performance diff between rendering partial vs. calling a hel

**URL:** <https://www.ruby-forum.com/t/performance-diff-between-rendering-partial-vs-calling-a-hel/98325>\
**Category:** Rails\
**Created:** [July 13, 2006, 10:10pm UTC](https://www.ruby-forum.com/t/performance-diff-between-rendering-partial-vs-calling-a-hel/98325 "2006-07-13T22:10:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![justincollins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@justincollins](https://www.ruby-forum.com/u/justincollins)\
**Post date:** [July 13, 2006, 10:10pm UTC](https://www.ruby-forum.com/t/performance-diff-between-rendering-partial-vs-calling-a-hel/98325/1 "2006-07-13T22:10:45Z")

</div>

Hi,

Is there any performance difference between rendering partials vs.  
calling a  
helper? When we initally started coding we built a bunch of small  
partials  
and if there is a significant performance overhead with them, we’ll  
probably  
try to switch them over to helpers. They seem like they would be quite  
similar but I don’t know the full details of how partials are handled.

Thanks!  
Justin

---

<div class="post-metadata">

**Author:** ![justincollins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@justincollins](https://www.ruby-forum.com/u/justincollins)\
**Post date:** [July 13, 2006, 10:57pm UTC](https://www.ruby-forum.com/t/performance-diff-between-rendering-partial-vs-calling-a-hel/98325/2 "2006-07-13T22:57:38Z")

</div>

Justin C. wrote:

> Is there any performance difference between rendering partials vs.  
> calling a helper? When we initally started coding we built a bunch of

Partials are just using the builtin ERB module that comes with Ruby. It  
has to read in the template file, parse the ERB and generate ruby, then  
eval the entire thing vs. just executing a function…

So if you really want to get to the nitty gritty partials should be  
slower. You would have to do performance tests to find out how much.

That being said, this sounds like premature optimization to me. If your  
performance tests tell you that you need to make your view render faster  
then maybe consider doing this. But there are probably other ways to  
increase performance that will deliver better results and keep your code  
maintainable. When deciding between partials and helpers just figure out  
what is the most maintainable. Only if you can measure a performance  
problem should you make a decision to do something in a less  
maintainable way. Otherwise you are just guessing and making your code  
less maintainable.

Eric

---

<div class="post-metadata">

**Author:** ![justincollins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@justincollins](https://www.ruby-forum.com/u/justincollins)\
**Post date:** [July 14, 2006, 2:02am UTC](https://www.ruby-forum.com/t/performance-diff-between-rendering-partial-vs-calling-a-hel/98325/3 "2006-07-14T02:02:07Z")

</div>

Thanks for the explanation and advice!

Justin

---

<div class="post-metadata">

**Author:** ![justincollins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@justincollins](https://www.ruby-forum.com/u/justincollins)\
**Post date:** [July 14, 2006, 1:41pm UTC](https://www.ruby-forum.com/t/performance-diff-between-rendering-partial-vs-calling-a-hel/98325/4 "2006-07-14T13:41:50Z")

</div>

Eric A. wrote:

> Justin C. wrote:
> 
> > Is there any performance difference between rendering partials vs.  
> > calling a helper? When we initally started coding we built a bunch of
> 
> Partials are just using the builtin ERB module that comes with Ruby.  
> It has to read in the template file, parse the ERB and generate ruby,  
> then eval the entire thing vs. just executing a function…

This used to be the case in older Rails versions. Now, templates are  
read only once and compiled into a render method, which will be called  
when rendering the template. So this is a lot faster than it used to be.

However, there’s still some overhead over simply calling a helper  
method: rendering a partial involves a few more method calls and some  
hash massage before the partial render method is invoked.

– stefan

–  
Rails performance tuning: [RailsExpress.blog](http://railsexpress.de/blog)  
Subscription: [railsexpress.de](http://railsexpress.de/blog/xml/rss20/feed.xml)
