FuzzyBlog

Scott Johnson / The FuzzyGroup, Feedster / PHP Consulting / Random geeky stuff / I Blog Therefore I Am.

 Friday, June 13, 2003

SmartTemplate versus Smarty: A Crude Analysis and a Question

***

Note: It is important to note in advance that this posting is not in anyway a "dissing of Smarty".  Smarty is very cool, very powerful BUT I've had performance troubles and I've never taken the time to address them fully.  It was faster and easier to just re-architect w/ SmartTemplate.  So don't think this as a "smarty don't work or smarty isn't fast post at all".  For my needs SmartTemplate seemed to be a better match.  That's all.

***

When I started moving Feedster to Smarty, Kalsey via IM waved his virtual finger at me and said "No, no no -- SmartTemplate".  I merrily went on my way only to hit major performance issues with Smarty and then I remembered what he said. I swore at myself for a while and then proceeded to re-work Feedster with SmartTemplate.  The results?  Interesting.  Very interesting.  Here's a dump from a crude ass benchmark:

Smarty: Execution took 4.680962 seconds

SmartTemplate: Execution took 0.392780 seconds

Now this isn't a 100% fair comparison -- When I redid it with SmartTemplate I did restructure my overall templating approach a bit and clean it up.  It's not quite apples versus apples.  But it also isn't apples versus oranges either -- more apples versus pears I'd say.

Could I have gotten better results with Smarty?  Yes.  I strongly suspect so.  Would it have taken me more effort than re-architecting code.  Unclear.  So why did I take the radical approach?  8,166 bytes + 8.671 bytes.  That's the size of SmartTemplate.  Now Smarty is 90,564 + if I understand it correct the smarty compiler class which is 67,135 bytes.  That's what -- a 6 to 10 fold decrease in include library size?  That's a huge performance win for us since close to every single Feedster page is templated.

Rule of Thumb: Its not just code speed.  Code size matters too. 

The Question

So here's the question.  My rss generation templates start with an xml declaration like this: <?xml version="1.0" ?>

How do I get SmartTemplate to not parse that (right now it tosses a PHP error at me).

When: 10:20:50 AM  | Permalink:   | comment []  |  IM Me About This   

PHP Performance Questions: Global versus Parameter Passing ?  Which one rocks?

So here's a question that just struck me -- what's faster in php -- using global to import a variable into local scope or passing it as a parameter to a function.  Clearly either works but which one is better?  And does it matter whether it is a simple variable, an object or an array or an associative array?

As they say: "Inquiring Minds Want to Know".

When: 9:12:20 AM  | Permalink:   | comment []  |  IM Me About This   

June 2003
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
May   Jul

Blog Home

Click here to send an email to the editor of this weblog.

Click to see the XML version of this web page.



Search My Blog



All Posts

Powered by:



My Businesses







About Scott Johnson




Books I've Written







BlogRoll



The FuzzyBlog! © Copyright 2003, The FuzzyStuff.
Last update: 7/1/2003; 6:21:55 AM.