Smarty benchmark, anyone?

前端 未结 10 1931
旧时难觅i
旧时难觅i 2021-01-05 05:05

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

相关标签:
10条回答
  • 2021-01-05 05:18

    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

    0 讨论(0)
  • 2021-01-05 05:20

    You might also want to take at a new template library that is similar to Smarty called Dwoo

    0 讨论(0)
  • 2021-01-05 05:20

    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).

    0 讨论(0)
  • 2021-01-05 05:21

    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.

    0 讨论(0)
  • 2021-01-05 05:23

    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...

    0 讨论(0)
  • 2021-01-05 05:28

    Just found this very simple benchmark - propably not very significant.

    0 讨论(0)
提交回复
热议问题