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

Caching and performance

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


Joined: 11 Apr 2011
Posts: 4

PostPosted: Mon Apr 11, 2011 3:44 pm    Post subject: Caching and performance Reply with quote

Hi all,

I am benchmarking smarty with ab for a project I have.

Plain php echo's: 1833 requests per sec.
Smarty tpl: 138 requests per sec.

I was expecting some penalty for using a template engine but not that much. There must be something wrong in the way I perform the benchmark. Or the way I enable caching.

Plain php test file:
Code:
<?php echo "Name: $name\n"; ?>
<?php echo "Address: $address"; ?>

Smarty files:
Code:
$smarty_path="/var/lib/smarty";

require('smarty3/Smarty.class.php');
$smarty = new Smarty();

$smarty->setTemplateDir($smarty_path.'/templates');
$smarty->setCompileDir($smarty_path.'/templates_c');
$smarty->setCacheDir($smarty_path.'/cache');
$smarty->setConfigDir($smarty_path.'/configs');
$smarty->setCaching(Smarty::CACHING_LIFETIME_CURRENT);

$smarty->assign('name', 'george smith');
$smarty->assign('address', '45th & Harris');

$smarty->display('index.tpl');

index.tpl
Code:

Name: {$name}
Address: {$address}
Back to top
View user's profile Send private message
esperlu
Smarty n00b


Joined: 11 Apr 2011
Posts: 4

PostPosted: Wed Apr 13, 2011 7:19 am    Post subject: Reply with quote

I have made a couple of tests and the smarty caching seems to work ok but the perf. are still lagging.

I compared plain html, smarty and a lightweight template engine (rainTPL). I know that these two template engines are not to be compared as rainTPL is missing a lot of features that smarty has. RainTPL with its 8 tags and 3 methods is only suited for simple sites. But it is fast.

Testing method:
ab -n 100 -c 10 <url>

Plain html: 2700 requests per sec.
rainTPL: 392 requests per sec.
smarty3: 119 requests per sec.

As I will probably be choosing smarty for its power and feature list, I was wondering if I could fine tune it to make it snappier.
Back to top
View user's profile Send private message
ndorphin
Smarty Rookie


Joined: 24 Dec 2009
Posts: 15
Location: Berlin, Germany

PostPosted: Mon May 16, 2011 11:43 pm    Post subject: Reply with quote

Maybe this simple test case doesn't profit from caching? I use smarty caching for really complex pages, without caching the renderring time is some seconds, with smarty caching ~0.2 seconds. Generally smarty caching is not the solution to speed up any page (there are others like proxy etc), it's more an additional benfit if you need the options of a complex template engine...

ndorphin
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