|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Dec 03, 2012 2:11 am Post subject: I've noticed, you was serious about Smarty performance... |
|
|
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 |
|
|
|
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
|