Smarty 2.6, 3.0beta and Dwoo Performances

UPDATE : July 20, 2010
New tests on Smarty 3.0 : RC1, RC2 and RC3 shows same performances as Smarty 3.0b9, no major change. These Release Candidate fix some bug and security issue and give a better stability.

Smarty 2.6, 3.0beta and Dwoo Performances

The aim of this test is to evaluate which template engine is the more efficient in professionnal environment. I selected only Smarty and Dwoo. Smarty is the template engine which we use at Emisfr since 3 years, we know it and we have many application working with. Dwoo is a Smarty « fork » but with a great Oriented Objet improvement. Smarty 3.0 is currently in developpement and one of its aim is to bring Smarty totaly Object and support Objet inside template, Smarty 2.x is likely PHP4 oriented, functional not really object. There is some other template engines like Template Lite (it’s also a Smarty « fork »).

Test environment

dual core Athlon 4200+
3.3Gb RAM
Apache : 2.2.13
Mod_PHP : 5.2.11 + APC
Apache Bench : 2.3

Tested versions

Smarty 2.6.26 : current stable
Smarty 3.0b7 : previous beta, usefull to compare evalution between betas
Smarty 3.0b8 : current beta
Dwoo 1.1.1 : current stable

The tests

Display of a template with and without template engine cache. We are talking about Template engine cache, not APC. When template engine cache is enable, the template engine have not to re-generate PHP code from Template file (tpl).
We will have a look on Memory peak and display time.

Cache enabled
Optimized Site
Force compile
Only to get performances
but this configuration never use
in production
Force Compile Check
Developpment configuration
no cache
No Compile Check
Production Site
most common configuration
cache_lifetime=-1
caching=1
force_compile=false
cache_lifetime=0
caching=0
force_compile=true
cache_lifetime=0
caching=0
check_compile=true
cache_lifetime=0
caching=0
check_compile=false
KINDTEST s3b8_rps s3b8_tpr s3b7_rps s3b7_tpr s2_rps s2_tpr dwoo_rps dwoo_tpr
cache_enabled 167,98 29,77 186,67 26,79 247,05 20,24 187,85 26,62
force_compile 16,33 306,24 16,72 299,05 62,38 80,15 37,2 134,41
force_checkcompile 126,96 39,38 131,83 37,93 187,37 26,69 108,49 46,09
no_checkcompile 127,39 39,25 132,69 37,68 184,89 27,04 111,99 44,65
Libraries Size
Template Engine Size (ko) File count
Smarty 2.6.26 223Ko 69 files
Smarty 3.0b7 627,8Ko 177 files
Smarty 3.0b8 635,4Ko 103 files
Dwoo 1.1.2 396,2Ko 101 files

Next we will test performances with hight access to the test page. For theses tests I will use « ab » (apache bench) with the following parameters : 1000 requests, 5 concurrency. We shall study requests per second, time per request and failed requests.

Execution time for the test page

Execution time
Execution time

When the cache is enable the results are closed, Smarty 2.6 have an advantage over others. But all are above 50ms. Smarty 2.6 and Smarty 3.0beta are very closed, with less than 15ms, it’s the best score.

When force compile is enabled, we can see Dwoo and Smarty 2.6 are the better, above 60ms. But Smarty 3.0beta is 3times slower than Smarty 2.6 with an execution time higher than 110ms. Don’t forget Template Engine force compile option is never enabled in production, this is a test to know « who is the best ».
In « developpment » configuration, result are good, lower than 15ms for evryones, Smarty 2.6 keeps head with 8ms.
In « common production » (no compile check), results looks like « developpment ». The deferencies between them are insignifiant.

Memory print

Memory
Memory

Previously we see that Smarty 2.6 is the faster Template Engine, now what is there memory prints.
Dwoo and Smarty 2.6 are below than 1,7Mo is a good score.
But like execution time the more important is when the cache is enabled. The template engines are below than 850 Ko, Smarty 2.6.26 is about 590 Ko this is the better score Smarty 3.0beta and Dwoo are about 800Ko.

When a Template Engine is configured in « force compile » mode, the Engine have to compile the templates files each time. We can see Smarty 3.0beta consum 2 times more than Smarty 2.6 : 2,4 Mo. Dwoo is juste behind Smarty 2.6 with 1,5Ko

When force check compile is enabled all are above 760ko (the bests scores), why Smarty use less memory than « cache enabled » ? I have no response yet.

When force compile si disabled, results are exactly sames.

Request per seconde

Request per second
Request per second

To simulate a high traffic on the test page I use apache bench, first when force compile is enabled, the results are likely Execution time test above. We can see Smarty 2.6 is the faster Template Engine with about 60 request per second, Dwoo is behind with 40 request per second and Smarty 3.0beta lag behind with 20 requests per seconde (3 time slower than Smarty 2.6).
When the Template Engine Cache is enabled all performances are satisfactory with more than 160 request per second. Smarty 2.6 is still the better with 247 request per second. Dwoo and Smarty 3.0beta are closed with 180 request per second.
In « force check compile » results are good, with more than 125 request per second. But Smarty 2.6 is 30% Faster than Smarty 3.0b. There is no major differencies when « No check compile » is enabled.

Theses results are the reflection of the previous Execution time test

Time per request

Time per request
Time per request

To finish this study, we have a look to the average time per request. Like others tests, When force compile is enabled, Smarty 2.6 is still the faster, with 80ms per request, dwoo is behin with about 135ms per request, Smarty 3.0beta are in the dust with more than 290ms per request.
When cache is enabled all competitor are closed, with a good score below than 30ms per request, Smarty 2.6 takes head with less than 21ms per request.
In force check compile configuration, the results are good with less than 40ms for Smarty, but Smarty 2.6 is the better. When check compile is disabled, the results are close with « force check compile », no major differencies.

To conclude, Smarty 2.6.26 is the better, faster and lighter template engine. Dwoo is a good alternative but its performances are worst than Smarty 2.6.26 and it’s not totally compatible with current Emisfr Software. Smarty 3.0 is good, but is a consume some more memory, but it’s very good score for a beta. The results of Smarty 3.0b are very close with Smarty 2.6.26. The developpment team do a good job ! But, don’t forget Smarty 3.0 is beta, may be some improvement will come.
This test will be updated with Template Engine evolution and release.
Emisfr is using Smarty 2.6.x but hope switch to Smarty 3.0 when it will be released as stable.

Test Files :
Smarty Test Files Package

Follow discution about this test on Smarty forum

Une pensée sur “Smarty 2.6, 3.0beta and Dwoo Performances”

Les commentaires sont fermés.