Forum: Ruby on Rails Using partials - performance impact

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
755d28f5c7e6b1af2fbe349b179fe220?d=identicon&s=25 Jason Reed (Guest)
on 2007-04-25 18:19
I love partials -- no question about how you can logically separate the
components of a view and of re-use it in many places.

My question to the experts is - what (if any) performance impact does
this have in production environment? It can't be all good news right? Or
is it?

For example -

Case 1 : All the view rhtml is stored in one file - no partials

Case 2 : The same rhtml is generated using 10 partials with objects
passed into partials using :locals.

Note that the end result of case 1 and case 2 is the exact same html.

How does case 1 compare with case 2? I do hope to do some tests and will
share results with the forum.

Thanks.

JR
755d28f5c7e6b1af2fbe349b179fe220?d=identicon&s=25 Sandy Jimenez (Guest)
on 2007-04-26 06:41
Jason Reed wrote:

> My question to the experts is - what (if any) performance impact does
> this have in production environment? It can't be all good news right? Or
> is it?
>

There is some file IO associated with reading more than one file. I
would recommend using partial where it makes logical sense.

Let us know what your testing reveals.

Sandy --
6925c1e7ea432d878f1832d857d6dfe8?d=identicon&s=25 Richard Luther (Guest)
on 2007-04-26 09:37
(Received via mailing list)
Good questions. While my test isnt the most detailed and doesnt have
10 different partials (only 2) It does demonstrate a "slight" speed
increase for straight rhtml.
I tested straight rhtml, partial with a collection and partial with
local. The html for th collection is a little different...too lazy to
fix.
Feel free to take the app and modify it to make the test more
detailed. You can download the app here:
http://www.tangofoxtrot.com/assets/2007/4/26/parti...
Uses sqlite3 and railsbench.

I tested using railsbench perf_run 200 -bm=main_controller

the results:

loading environment                 2.06392

page request                          total  stddev%     r/s    ms/r
main_index                          3.94083   9.4458   50.75   19.70
main_collection_index               4.41511   7.0973   45.30   22.08
main_local_index                    4.24100   6.4577   47.16   21.21

all requests                       12.59695   7.1636   47.63   20.99

- Richard

On Apr 25, 9:19 am, Jason Reed <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.