Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
I've noticed, you was serious about Smarty performance...

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
AnrDaemon
Smarty Pro


Joined: 03 Dec 2012
Posts: 106

PostPosted: Mon Dec 03, 2012 2:11 am    Post subject: I've noticed, you was serious about Smarty performance... Reply with quote

Here's a short script to demonstrate one performance issue:
Code:
<?php

for($i = 0; $i < 128; $i++)
  $a[trim(pack('V', $i))] = $i;

$i = 0;
$_time = microtime(true);

while($i < 100000)
  if(array_key_exists('k', $a))
    $i++;

$_ake = microtime(true) - $_time;

$i = 0;
$_time = microtime(true);

while($i < 100000)
  if(isset($a['k']))
    $i++;

$_is = microtime(true) - $_time;

printf('isset() is %.2f times faster, than array_key_exists()', $_ake / $_is);


Unless you REALLY want to check for presence of array keys with NULL values, the performance gain is considerable.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development 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