Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Benchmark Smarty 2.6.26 VS Smarty 3.0b7, 3.0b8 and Dwoo

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
cferry
Smarty Rookie


Joined: 17 Jun 2009
Posts: 9

PostPosted: Mon Mar 29, 2010 7:48 am    Post subject: Benchmark Smarty 2.6.26 VS Smarty 3.0b7, 3.0b8 and Dwoo Reply with quote

Hello,
there is a benchmark about Smarty 3.0, compared to Dwoo and Smarty 2.6.26
English | French

Hope it will usefull.
Regards
CÚdric
Back to top
View user's profile Send private message
Lemon Juice
Smarty Pro


Joined: 24 May 2006
Posts: 109

PostPosted: Mon Mar 29, 2010 4:46 pm    Post subject: Reply with quote

Interesting test, thanks. It would be good if you also mentioned what kind of page you tested because we don't know how complex the tpl files were, how big, how much time was actually spent on fetching data from a database, etc.

BTW, I switched to Smarty 3 on a production site (this is a large online store) and no problems at all. There is a slight speed improvement which can't be noticed. Overall, it's been a positive experience.

I've read about Dwoo but I don't think it makes much sense to switch to Dwoo now that Smarty 3 is almost ready - that project would make sense if there was no development in Smarty 3 because version 2 is now quite obsolete. I image the project author got impatient last year and that is why he started Dwoo.
Back to top
View user's profile Send private message
cferry
Smarty Rookie


Joined: 17 Jun 2009
Posts: 9

PostPosted: Tue Mar 30, 2010 7:59 am    Post subject: Reply with quote

Yes, it's true, I just update the post with more detail about test pages.
The test page don't use database, It's just a template with arrays and object, the first aim is to test Smarty performances, and I think with a database, the results can be not representative. So this is a pure Smarty template with foreach, date_format...
If you have any suggestion to improve this test and make it more representative, i'm aware.

I use Smarty 3 too in some project but not yet on production.
I'm Ok with you, Dwoo is not useful right now with Smarty 3.
What do you think about memory usage ? have you an idea about it come from ?
Back to top
View user's profile Send private message
Lemon Juice
Smarty Pro


Joined: 24 May 2006
Posts: 109

PostPosted: Tue Mar 30, 2010 8:38 am    Post subject: Reply with quote

As to the memory usage Smarty 3 now creates a separate object for each variable passed through assign - so usually php needs to store many such objects in memory when a script is running. There are some features that this solution provides like specifying caching properties (the devs will be able to say more). Personally, I'd prefer variables to be just array or object members (like in smarty 2) just to keep it simple and the performance would be better. But since the overall speed has improved I don't mind. Perhaps in the future the devs will do something to decrease memory usage.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5063
Location: Hamburg / Germany

PostPosted: Tue Mar 30, 2010 2:24 pm    Post subject: Reply with quote

Hello Cedric

I just had a brief look at the files you used for the benchmark.

I haven't had the time yet to run tests with your files myself, but as it looks like you did run the test with force_compile = true. This is what you would not use on production servers. The Smarty3 compiling process is slower as with Smarty2 because of the lexer/parser concept we are using for better maintainabillity and easier extensions. Compiling is normally a one time only process so that time is not so important.

For benchmarking you should use force_compile = false. Execution time and memory usage should be much better for that case.

Uwe
Back to top
View user's profile Send private message
cferry
Smarty Rookie


Joined: 17 Jun 2009
Posts: 9

PostPosted: Tue Mar 30, 2010 3:02 pm    Post subject: Reply with quote

Uwe,
I do 2 kind of test, with force_compile and without (you can see it on the charts). I know this is not the configuration for production, (it's mentionned in my post). but it's useful to compare performances.
Please look the chart, you will see memory peak (and execution time) is less when cache is enabled, but higher than Smarty 2.6.
I don't understand why with cache disable the memory peak of Smarty 3.0b is 2 times bigger than Smarty 2.6.
I think it's a problem for cerain configuration with less than 24MB allowed for PHP process.
I know compiling is one time only, but if Smarty 3.0b eat 30MB (or more), and the config is max 24MB, the template will not compile. It's a real problem.
Don't forget the test page is very small with no database connection.
Imagine on a real site, with database and more template, more data, memory should be higher than 40MB.
I think some improvement can be do on compiling. I may took some time to look how.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5063
Location: Hamburg / Germany

PostPosted: Tue Mar 30, 2010 3:20 pm    Post subject: Reply with quote

There are two thinkable test cases with precompiled templates:

1. Caching disabled
force_compile = false
caching = false

2. Caching enabled
force_compile = false
caching = true

And one case for testing the compile time:
force_compile = true
caching does not matter much


What was your setting for the "without cache" case?

Uwe
Back to top
View user's profile Send private message
cferry
Smarty Rookie


Joined: 17 Jun 2009
Posts: 9

PostPosted: Tue Mar 30, 2010 3:25 pm    Post subject: Reply with quote

Uwe,

Cache enabled : 2. Caching enabled
force_compile = false
caching = true

Cache disabled (should be cache disabled and force compile) : force_compile = true

I will update the post.
CÚdric
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5063
Location: Hamburg / Germany

PostPosted: Tue Mar 30, 2010 4:14 pm    Post subject: Reply with quote

Also cache_lifetime = 0 is not good. It does force the creation of a new cache file foreach request and should only be used for debugging.

for benchmarking use cache_lifetime = -1 which means that the cache file does not expire.
Back to top
View user's profile Send private message
Lemon Juice
Smarty Pro


Joined: 24 May 2006
Posts: 109

PostPosted: Tue Mar 30, 2010 4:29 pm    Post subject: Reply with quote

cferry, yes, specifying what you mean by "with cache" and "without cache" on your site would help a lot. Personally, I would be much interested in benchmarking this setup:

force_compile = false
compile_check = true
caching = false

But it looks like you didn't use these settings. However, I suppose that compile_check is not something that should perform much differently than in smarty 2?

It's good you tested force_compile = true as well. While it's not for production it's good to be aware of CPU and memory requirements for compiling.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5063
Location: Hamburg / Germany

PostPosted: Tue Mar 30, 2010 4:32 pm    Post subject: Reply with quote

Cedric

Some more is incorrect. You wrote that the memory usage was 24Mio. You made an general error. It's 2.4 Mio and ten times lower for all other values.

Smarty3 does load all plugins as they are required. Also your assumption in this case was wrong.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5063
Location: Hamburg / Germany

PostPosted: Tue Mar 30, 2010 7:46 pm    Post subject: Reply with quote

Next problem is that your report.tpl did calculate the run time completely wrong. You can't subtract the result of microtime() and $_SESSION['REQUEST_TIME'] directly because both are strings with a separate section for microseconds and seconds.

Instead you could use code like this in bench.php
Code:
<?php
function _get_time()
    {
        $_mtime = microtime();
        $_mtime = explode(" ", $_mtime);
        return (double)($_mtime[1]) + (double)($_mtime[0]);
    }
$start = _get_time();

// all code here

echo '<br>memory '.memory_get_peak_usage(true).'<br>time '.(_get_time() - $start);

Back to top
View user's profile Send private message
cferry
Smarty Rookie


Joined: 17 Jun 2009
Posts: 9

PostPosted: Wed Mar 31, 2010 9:36 am    Post subject: Reply with quote

Hi Uwe,
I update the time test with you suggestion, and we can see Smarty 3.0b is really fast.
I update Memory numbers, so the Smarty 3.0 consume more memory than Smarty 2.6 but it's acceptable (2.4Mo).

I will re-test with this new settings + compile_check.
Code:

Cache enabled         Force compiling           Force Check compile     No compilation check
cache_lifetime=-1     cache_lifetime=0          cache_lifetime=0        cache_lifetime=0
caching=1             caching=0                 caching=0               caching=0
force_compile=false   force_compile=true        check_compile=true      check_compile=false




Code:

Smary 3.0b8

                  Request/Sec     Time/Req
cache_enabled       167,98        29,77
force_compile        16,33        306,236
force_checkcompile  126,96        39,38
no_checkcompile     127,39        39,25



When compile_check is disabled, Smarty is a little faster, but not so much.
I will update the post on my blog soon.

EDIT : Article updated

CÚdric
Back to top
View user's profile Send private message
cerverg
Smarty n00b


Joined: 17 Apr 2010
Posts: 3

PostPosted: Sat Apr 17, 2010 7:14 pm    Post subject: Reply with quote

Why there is no test with
caching=2
cache_lifetime=300
force_compile=false

Who cares about results with "force_compile=true"
Back to top
View user's profile Send private message
cferry
Smarty Rookie


Joined: 17 Jun 2009
Posts: 9

PostPosted: Mon Apr 19, 2010 9:22 am    Post subject: Reply with quote

@cerverg
force_compile is usefull to know improvement on compiler.
You can download the source's archive on my blog to test with your own settings.

CÚdric
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP