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

Performance of Smarty 2 vs 3

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


Joined: 10 Jun 2011
Posts: 4

PostPosted: Fri Jun 10, 2011 10:23 pm    Post subject: Performance of Smarty 2 vs 3 Reply with quote

Hi everyone, my company website decided to upgrade to smarty 3 from smarty 2.
However, we have noticed big difference in performance. So we made the following benchmarks for analysis.

Background:
- Script is doing 500 runs of a function, with 450 microseconds sleep in between.
- Each function includes instantiation of the smarty object, a $smarty->display of a base template that includes a header tpl, display the content of a fetched footer tpl and one simple assigned var.
- No template compiling was required. (Tpls were already compiled.)
- Then an average elapsed time is calculated and stored in session

Result - Smarty 2:
Code:

2.6.19  // smarty version

previous:
Array
(
    [0] => 0.0007626276032     // average elapsed time of 500 $smarty->display()
    [1] => 0.0006898279186
    [2] => 0.0007515878676
    [3] => 0.0007296662286
    [4] => 0.0006703367236
    [5] => 0.000763019561
    [6] => 0.0006627821936
    [7] => 0.00067408991
    [8] => 0.0006789131152
    [9] => 0.0007295136448

Avg from previous
0.00071123647662        // average elapsed time of 10 runs


Result - Smarty 3:
Code:

Smarty-3.0.8       // smarty version

previous:
Array
(
    [0] => 0.001182794093    // average elapsed time of 500 $smarty->display()
    [1] => 0.0011434893604
    [2] => 0.0010536174778
    [3] => 0.0010419712094
    [4] => 0.0011102046968
    [5] => 0.0010875434872
    [6] => 0.0011334052082
    [7] => 0.0011139659906
    [8] => 0.0011450152376
    [9] => 0.0011299881958

Avg from previous
0.00111419949568        // average elapsed time of 10 runs


You can see that the performance of smarty 3 is no better than smarty 2. And we cannot enable tpl caching since we implements our own caching system.

Would anyone be able to advise me on this? Thanks in advance.
Back to top
View user's profile Send private message
catherinek
Smarty n00b


Joined: 10 Jun 2011
Posts: 4

PostPosted: Fri Jun 10, 2011 10:30 pm    Post subject: Reply with quote

To provide better investigation, I have included the contents of templates below.

Code:

// base.tpl.smrt
<!DOCTYPE>
<html>
{$PAGEHEADER}

{$CONTENT}

{include file="page_footer.smrt.tpl"}

</html>

Code:

// header.tpl.smrt
<head>
   <title>{$version} Benchmarking</title>
</head>
<body>
   <div>
      <h2>This is the header</h2>
   </div>

Code:

// footer.tpl.smrt
<div>
   <h5>This is the footer</h5>
</div>
</body>
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7366
Location: Lincoln Nebraska, USA

PostPosted: Sat Jun 11, 2011 12:24 am    Post subject: Reply with quote

Smarty 3 probably isn't going to out perform Smarty 2 in very simple cases. Most improvements are seen in more complete use-cases (many tpl includes, etc.) It would be interesting to see how your tests look against 3.1 beta, which is currently available in the branches directory. 3.1 has many internal performance tweaks that may affect simpler cases.

http://smarty-php.googlecode.com/svn/branches/Smarty_3_1_DEV/
Back to top
View user's profile Send private message Visit poster's website
catherinek
Smarty n00b


Joined: 10 Jun 2011
Posts: 4

PostPosted: Mon Jun 13, 2011 9:27 pm    Post subject: Reply with quote

With the Smarty 3.1, I got similar results:
Code:

previous:

Array
(
    [0] => 0.0012894601822
    [1] => 0.001198319913
    [2] => 0.0011763463018
    [3] => 0.0013183712972
    [4] => 0.001187467099
    [5] => 0.0012516894328
    [6] => 0.0013002882008
    [7] => 0.0013055953968
    [8] => 0.0012157382966
    [9] => 0.001209300044

Avg from previous
0.00124525761642


I will try with more complicated tpls and let you know the new results.
Back to top
View user's profile Send private message
catherinek
Smarty n00b


Joined: 10 Jun 2011
Posts: 4

PostPosted: Mon Jun 13, 2011 10:34 pm    Post subject: Reply with quote

The following results are from a more complicated header and footer tpls, which uses {include}, customized modifiers, functions..etc.

Code:

Smarty-3.0.8

previous:
Array
(
    [0] => 0.0055827355404
    [1] => 0.0044862246486
    [2] => 0.0047061548246
    [3] => 0.004451875687
    [4] => 0.0045937981606
    [5] => 0.0045898985858
    [6] => 0.0046687583936
    [7] => 0.0046631679532
    [8] => 0.0047636103614
    [9] => 0.0044418573356

Avg from previous
0.00469480814908


Code:

2.6.19

previous:
Array
(
    [0] => 0.0063177995684
    [1] => 0.0033681116114
    [2] => 0.0035613412864
    [3] => 0.0033461551666
    [4] => 0.0034709763512
    [5] => 0.003322841169
    [6] => 0.0032990508072
    [7] => 0.0032554988854
    [8] => 0.0035109596236
    [9] => 0.0034584960948

Avg from previous
0.0036911230564
Back to top
View user's profile Send private message
yli
Smarty Rookie


Joined: 02 Jul 2010
Posts: 15

PostPosted: Sat Jul 09, 2011 6:29 pm    Post subject: hmmmm Reply with quote

maybe i'm not the right person to comment on this post because i'm a newbie with php and smarty.
i think is normal to don't see any diference ... behind the smarty is php and your php version and your functions are unchanged so...
is smarty changing your php code and optimize it?
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