[development] Note that PHP arrays are fast
Doug Green
douggreen at douggreenconsulting.com
Tue Apr 10 13:59:48 UTC 2007
My two cents are added to the closed ticket http://drupal.org/node/134697
Basically:
* modulo is slower than bitwise-and and I think that this was the main
culprit to the even/odd flip performance
* microtimer is not a benchmarking tool
Doug Green
904-583-3342
www.douggreenconsulting.com
Bringing Ideas to Life with Software Artistry and Invention...
Providing open source software political solutions
-----Original Message-----
From: development-bounces at drupal.org [mailto:development-bounces at drupal.org]
On Behalf Of Karoly Negyesi
Sent: Monday, April 09, 2007 8:19 PM
To: development at drupal.org
Subject: [development] Note that PHP arrays are fast
Hi,
Note my trick in http://drupal.org/node/134697 which shows that the hash
lookups in Zend Engine are a bit faster than branching.
Instead of
$class = $class == 'even' ? 'odd' : 'even'
we have
$flip = array('even' => 'odd', 'odd' => 'even');
$class = $flip[$class];
The first can be as much as 10% slower. I will explore this area further
and I recommend everyone to familiarize themselves with the vast array of
php array functions :) because next Drupal will be even more abound with
arrays.
Regards,
NK
More information about the development
mailing list