ruby on rails - Is calling a partial an expensive operation? -


Can I use as much as I want to partially or should I avoid getting my ideas crawled Do you have to stop the traffic yourself?

There is a clear overhead using partial but it's not something you should worry about.

There are partial files when you present partially without any action, then your action "cost" 1 file (this is not entirely true, but it is easy to clarify). If your action offers 4 partially, then you end up with the cost of 5. This means, you have 4 additional IO calls and the actual cost for each call depends on your server load, server performance and so on.

But does this cost difference? In my experience, 99% times no. In addition, the benefits of partial use in terms of code readability and maintenance are generally worth choice.

If performance should be an important feature, then you should probably seek speed and improvement somewhere else.

Remember: Ruby is not a super fast programming language and code expression always takes precedence. In place of performance, Rail Rail has agreed to this conference, although the rail team always focuses on demonstrations (And Rail 3 is a practical demonstration that is always a place of improvement)

He said, you can partially use partially and reduce application overhead. For example, with some cautious caching mechanisms, you can do the rendering of a collection within a cache block so that a render collection statement is executed only once, then your app can only show 10 non-cached Instead of partial 1 cache file will load.

One of the most annoying errors I did several times in the beginning was to worry about performing improperly, said, without really running the standard. I remember once when I was trying to leave a single database query in favor of a hard-coded hash because "query cost", without feeling that there was another stupid query in which an entire table collection is included without loading As a result, the second question is slowing down 3 times.

Therefore, if you really care about performance, then you should not use partially, but instead make sure that you are taking advantage of all the other amenities the railway provides you on the scale Is your application?


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -