Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

I've noticed, you was serious about Smarty performance...

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

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:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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