Using partials - performance impact


#1

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


#2

Jason R. 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 –


#3

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/partial_test.zip
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 R. removed_email_address@domain.invalid