Performance effect using $this -> render(); while developing a layout?

154 Views Asked by At

A lot of time, it becomes necessary to separate some section commonly used like banner, footer to a separate file and later on include this parts as $this -> render('banner.phtml').

When this is used extensively, how costly does it become performance wise?

2

There are 2 best solutions below

0
On BEST ANSWER

I don't think that it has some sort of bad effect on performace. I am working on very large product and I have extensively used $this->render() in my project for handling various things. If you are not having a common layout then you have to rely on this function. But if you are having a common layout throughout the project, then there is no need of this. So don't worry on using the render function.

0
On

Looking at the code of Zend_View_Abstract it should be fine do have multiple calls. render() essentially does:

  • Look up the script. One operation for each scriptpatch you have.
  • Run the file, encapsuled by ob_start() and ob_get_clean(). Should not cause any performance issues.
  • Run each filter on the output.

Unless you don't have hundreds of scriptpaths' or filteres added, performance should be ok. Note however that especially nested render() calls require more memory (due to possibly stacked output-buffers).

But of course you want to cache as much as possible anyway - making most of the render()-calls run only once ;).