Intro A list of micro-optimization tests / benchmarks. No guessing - just code and results. See testing page if you want to know the details of how each micro-optimization was tested. Add new code for the comparison - the tests will be run shortly.
is_a vs instanceof Submitted by gekkie on Tue, 05/15/2012 - 15:25 f1 is slower than f2 by 0% 50% updown50%
Use empty function or direct comparison (with undefined variable) Submitted by Lito on Tue, 03/27/2012 - 12:48 f2 is slower than f1 by 799.89% (8 times slower)50% updown50%
Use empty function or direct comparison (with defined variable) Submitted by Lito on Tue, 03/27/2012 - 12:41 f2 is slower than f1 by 4.95% 50% updown50%
str_replace vs implode explode Submitted by kgruszczynski on Thu, 03/22/2012 - 00:40 f1 is slower than f2 by 148.1% (1.5 times slower)50% updown50%
str_replace vs preg_replace (without regular expression) Submitted by Lito on Fri, 03/16/2012 - 15:48 f2 is slower than f1 by 40.33% 50% updown50%
file_exists vs is_file (existing files with error ignore) Submitted by Lito on Fri, 03/16/2012 - 15:45 f1 is slower than f2 by 68.72% 50% updown50%
file_exists vs is_file (non existing files) Submitted by Lito on Fri, 03/16/2012 - 15:43 f1 is slower than f2 by 8.03% 50% updown50%
file_exists vs is_file (existing files) Submitted by Lito on Fri, 03/16/2012 - 15:38 f1 is slower than f2 by 150.73% (1.5 times slower)50% updown50%
Extended if vs short if Submitted by Lito on Fri, 03/16/2012 - 15:31 f2 is slower than f1 by 1.36% 50% updown50%
String concatenate vs implode() Submitted by darraghenright on Sun, 02/05/2012 - 18:45 f2 is slower than f1 by 10.05% 50% updown50%
drupal_static normal vs advanced usage Submitted by admin on Thu, 06/23/2011 - 21:21 f1 is slower than f2 by 1765.96% (17.7 times slower)50% updown50%
Access 1-dimentional array normally vs alias (reference) Submitted by admin on Wed, 06/01/2011 - 22:26 f1 is slower than f2 by 5.78% 50% updown50%
Access array normally vs alias (reference) Submitted by admin on Wed, 06/01/2011 - 22:15 f2 is slower than f1 by 4.59% 50% updown50%
Inside foreach: access to copied value vs access to the original array Submitted by admin on Wed, 06/01/2011 - 21:26 f2 is slower than f1 by 25.94% 50% updown50%
Equal vs identical comparison operator Submitted by tomek on Sun, 05/22/2011 - 18:38 f1 is slower than f2 by 134.38% (1.3 times slower)50% updown50%
echo vs printf Submitted by kgruszczynski on Sat, 05/21/2011 - 19:38 f2 is slower than f1 by 59.03% 100% updown0%
explode vs preg_split Submitted by tomek on Sun, 05/08/2011 - 14:03 f2 is slower than f1 by 55.94% 50% updown50%
isset vs array_key_exists Submitted by tomek on Sun, 05/08/2011 - 14:02 f2 is slower than f1 by 472.82% (4.7 times slower)50% updown50%
Single vs double quotes Submitted by tomek on Sun, 05/08/2011 - 14:01 f2 is slower than f1 by 1.66% 50% updown50%