s-cho-m
s-cho-m

Reputation: 1027

Does too many partial make the program speed slow with Rails?

Rails framework's partial feature is very useful for view. If use too many partial in a project, does it make the program load speed slow?

Upvotes: 0

Views: 320

Answers (2)

user4776684
user4776684

Reputation:

I think it should. It could be seen from the logs below that rendering time of large amount of the same partials is vary:

I, [2015-07-27T03:02:57.328508 #8369] INFO -- : Rendered properties/_property.html.erb (13.9ms) I, [2015-07-27T03:02:57.338626 #8369] INFO -- : Rendered properties/_property.html.erb (8.6ms) I, [2015-07-27T03:02:57.348418 #8369] INFO -- : Rendered properties/_property.html.erb (8.4ms) I, [2015-07-27T03:02:57.361821 #8369] INFO -- : Rendered properties/_property.html.erb (11.7ms) I, [2015-07-27T03:02:57.373611 #8369] INFO -- : Rendered properties/_property.html.erb (10.5ms) I, [2015-07-27T03:02:57.386695 #8369] INFO -- : Rendered properties/_property.html.erb (11.4ms) I, [2015-07-27T03:02:57.398740 #8369] INFO -- : Rendered properties/_property.html.erb (10.3ms) I, [2015-07-27T03:02:57.411959 #8369] INFO -- : Rendered properties/_property.html.erb (10.9ms) I, [2015-07-27T03:02:57.424705 #8369] INFO -- : Rendered properties/_property.html.erb (10.5ms) I, [2015-07-27T03:02:57.437990 #8369] INFO -- : Rendered properties/_property.html.erb (11.3ms) I, [2015-07-27T03:02:57.449926 #8369] INFO -- : Rendered properties/_property.html.erb (9.5ms) I, [2015-07-27T03:02:57.459979 #8369] INFO -- : Rendered properties/_property.html.erb (8.6ms) I, [2015-07-27T03:02:57.472241 #8369] INFO -- : Rendered properties/_property.html.erb (10.7ms) I, [2015-07-27T03:02:57.482611 #8369] INFO -- : Rendered properties/_property.html.erb (9.0ms) I, [2015-07-27T03:02:57.494238 #8369] INFO -- : Rendered properties/_property.html.erb (10.5ms) I, [2015-07-27T03:02:57.519543 #8369] INFO -- : Rendered properties/_property.html.erb (14.6ms) I, [2015-07-27T03:02:57.531808 #8369] INFO -- : Rendered properties/_property.html.erb (11.1ms) I, [2015-07-27T03:02:57.545017 #8369] INFO -- : Rendered properties/_property.html.erb (11.2ms)

In this particular log the timing distribution among the partials is not that large. However, there are cases where one partial loads 1ms and the next one is 10ms. It might be mostly due to SQLs delays in the partial, but in any case resource allocation during execution of partials will require some time, and it may become noticeable on large N.

Upvotes: 0

Elijah Woodward
Elijah Woodward

Reputation: 106

No, it shouldn't. In fact, utilizing subviews instead of having single giant views is the preferred way of doing things. If you use a Ruby IDE such as RubyMine it will actually complain if you don't use subviews when you have a single view that starts getting too large.

Upvotes: 1

Related Questions