Smarty: 0.029031 seconds
Smarty-Light: 0.011113 seconds
i would be more interested in the results of using Smarty and Smarty with an opcode-cache in relation.
Paul Lockaby wrote:
Hi everyone,
I got a few hits for my site because of the previous thread entitled Smarty Light. I would reply to that thread specifically, but I'm using email and I don't have the originals to reply to, so you get to live with a new topic. Sorry.
I did read the whole thread and it seems that there are some misconceptions about Smarty and speed. I'm not here to be down on Smarty, because it really is a revolutionary project for Template engines and PHP. It has a ton of features that really lots of people can't live without. It also inspired me and provided a code base for me to start from when I decided to fork Smarty and make my own.
Here is why I decided to fork Smarty: speed and features. I won't go into the features, because that's really not the point of this thread. I added a few that I wanted that were not entertained by the maintainers of Smarty and I removed a ton of features that Smarty had that I never used. That did, in fact, make the code base much faster.
I'm not sure about PHP5, but with PHP4, compilation time is directly related to the size of the PHP file and the complexity of any classes you have. As much as PHP tries to be an object oriented language, you still have to realize that every time a PHP page is called, it is recompiled by PHP and that takes time. Even if you only use three lines of your code and it exits on the fourth, if the code is 60kb, it will compile all 60kb.
That was the problem I saw with Smarty. The two files it uses to create templates are 65kb and 88kb. That's a lot of code if you just have a simple template. If you look at what I pared that down to, I only have 14kb and 27kb. Trust me, it makes a difference in compile times. But you don't have to trust me, I'll show you some unscientific numbers I just got off of my test webserver which is a private, NATed 466MHz Celeron with 512MB RAM and a 7200RPM HDD running Apache 1.3.31 and PHP 4.3.7.
First test page, doesn't load a thing, just instantiates the template object.
Smarty: 0.029031 seconds
Smarty-Light: 0.011113 seconds
Second test page, displays a compiled page with two variables and nothing else.
Smarty: 0.053641
Smarty-Light: 0.023038
The pages used to test the second numbers is available here:
http://www.paullockaby.com/pub/template_test.zip
Now granted, those numbers are small to begin with, but start loading lots of pages and it adds up.
Of course, I realize that this thread is really off topic for this forum and that I'll probably get whacked for posting stuff about my own template engine in here, but I felt it necessary to point out that class instantiation is slow and gets slower proportionally to the amount of code *and comments* in the class.
Thanks for your time.
Paul Lockaby