Page 1 of 1

How much Smarty is good for health??

Posted: Mon Oct 03, 2005 2:57 am
by psatish
Hi All

I have been working on a site with Smarty Template Engine and found it quite useful.

However I was wanting to know how much does Smarty, or any other template engine for that matter, affect performance?

My site needs one kind of navigation bar on the top and side to be shown when the user is not logged in and another kind to be shown when the user logs in.

So is it OK if I create template files that load based on the user's log in status OR is it better to include static PHP files?

Thanks and Regards

Posted: Mon Oct 03, 2005 3:25 am
by phpdevuk
smarty can be quicker for pages where alot of processing is done to create the page as it caches the pages it creates, meaning that frequently used pages will already be cached with out the need to processed. I've used smarty a few times now and I think it doesn't affect performance in any detrimental way, infact I normally notice pages loading faster if anything. About the only problem I ever had with smarty was with dreamweaver templates which just tore the website apart every time we tried to do an update.

Posted: Mon Oct 03, 2005 5:59 am
by psatish
Thanks for the reply phpdevuk.

Yes, since it caches the pages the overheads should not be more than loading a PHP page directly.

But what happens when the template changes? Smarty wipes out the old cache and puts in the new page? Maybe uses the file timestamp to check if the page changed?

Thanks and Regards

Posted: Mon Oct 03, 2005 7:41 am
by Maugrim_The_Reaper
Yep, it'll update the templates when changed based on modify time. Just be careful using the "caching" term with Smarty. It uses it in a different capacity to simple Template=>PHP caching as you referred to...

Posted: Mon Oct 03, 2005 8:54 am
by psatish
Maugrim_The_Reaper wrote:Just be careful using the "caching" term with Smarty. It uses it in a different capacity to simple Template=>PHP caching as you referred to...
Sorry, I am not sure I understood that. Could you please specify? Is that a security issue?

Thanks

Posted: Mon Oct 03, 2005 11:11 am
by Maugrim_The_Reaper

Posted: Mon Oct 03, 2005 5:54 pm
by McGruff
I think the key is to "compile" a run-time template in php so that there is no regex-ing going on when a request is made. WACT does this - Smarty too AFAIK.

Posted: Tue Oct 04, 2005 3:30 pm
by alvinphp
I have never used Smarty. I create my own classes and re-use them throughout my site. It is not that I am against frameworks, it is more that I first want to have a strong understanding of how to do everything myself first and then look into frameworks after. I admit I am weary of frameworks as they seem to change with the seasons.

Posted: Wed Oct 05, 2005 5:11 am
by Maugrim_The_Reaper
Smarty is a template engine - not a Framework. Horde, WACT, etc. are Frameworks. Actually I don't use frameworks myself - I rely entirely on a loosely bound base made up of common 3rd party libraries. It's something I'm looking to port into a single project on SF so its more easily utilised by anyone interested... I just find the usual frameworks a moving target with a steep learning curve...too much to invest for a benefit that's not all that apparent. Maybe I'm just a stickler for seeing all the processes in my applications...

Posted: Wed Oct 05, 2005 6:33 am
by n00b Saibot
Maugrim_The_Reaper wrote:I just find the usual frameworks a moving target with a steep learning curve...too much to invest for a benefit that's not all that apparent. Maybe I'm just a stickler for seeing all the processes in my applications...
This is the real thing... and since we're developers we do like to see all the processes in our applications :wink:

Yapter

Posted: Fri Oct 07, 2005 9:39 am
by []InTeR[]
I'm using yapter for a while now,

Easy to use template system. And it hardly changes.

http://yapter.sf.net

Posted: Tue Oct 11, 2005 4:10 pm
by Selkirk
Smarty is really designed to be used with an opcode cache. As long as you have one, you needn't worry about smarty's performance.

Here is an excerpt from the results of a benchmark from WACT, run without an opcode cache, that can give you an idea about the relative performance difference between using smarty and not using templates at all:

Code: Select all

no templates + Native SQL   Requests per second:    31.57 [#/sec] (mean)
Smarty + Native SQL         Requests per second:    7.00 [#/sec] (mean)