I am considering Smarty as my web app templating solution, and I am now concerned with its performance against plain PHP.
The Smarty site says it should be the same
here's another templating solution XSLT here are my benchmarks for one of the pages i converted (its a simple page):
// with smarty (baseline)
0.014 seconds
// with xsl/xslt-clientside
0.008 seconds
42% decrease in server stress
// with xsl/xslt-serverside
// this process would only be done if the users browser doesn't support client-side XSLT
0.016 seconds
14% increase in server stress
Its not for everyone but if performance is your main concern :)
On top of that you allow the client to cache your template.
here's an example of what I'm doing (this is one of my sites): http://pixao.com
and here's another example of it on a larger scale site: http://worldofwarcraft.com
so far i have yet to run into any show stoppers
You might also want to take at a new template library that is similar to Smarty called Dwoo
Smarty generates PHP code for all its template files when they're first used, provided you have it set up correctly, and uses them when possible instead of parsing the templates again.
I used it for a while and it was fast enough, but in the end I swapped it out for plain PHP files because it was a bit limiting (too many PHP4-isms).
Because in the end, Smarty compiles and caches the templates files to native PHP-code, there is indeed no theoretical performance difference. Of course there will always be some performance loss due to the chunk of Smarty-code that needs to be interpreted every time.
Smarty itself is rather a large library... If your going to use Smarty, I suggest you use APC to cache the compiled version.. It will offset the rather large size of the Smarty library...
Just found this very simple benchmark - propably not very significant.