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: |
|
IM Me About This
|