Strange performance difference between Ubuntu and Macports versions of PHP

Boomer531

New Member
After doing some profiling on a personal pet project, I'm playing around with some stupid micro-optimisations. It's largely an experiment more than anything else so the things I'm tweaking don't actually need to be tweaked. It's still an interesting exercise though.Anyway, I've come across a strange performance difference between my installation of PHP 5.3 on OS X through Macports and on Ubuntu from apt.It seems that the following code shows a massive speed difference between the two different versions on OS X, but only a minuscule speed difference on Ubuntu.\[code\]$x = array(9);// As per BarsMonster's comment, this ensures it runs for more// than a second in order to avoid possible kernel scheduler differences$count = 10000000;$s = microtime(true);for ($i=0;$i<$count;$i++) { $q = is_string($x);}var_dump(microtime(true)-$s);$s = microtime(true);for ($i=0;$i<$count;$i++) { // This is obviously only useful if you'll never need a string // with 'Array' in it here $q = (string)$x!='Array';}var_dump(microtime(true)-$s);\[/code\]The output when running on OS X:\[code\]float(17.977133989334)float(4.2555270195007)\[/code\]The output when running on Ubuntu:\[code\]float(5.2112979888916)float(3.4337821006775)\[/code\]It doesn't surprise me to see that the figures for the hacked up cast version are pretty similar, but the is_string method is wildly different.What can I attribute this to? If the performance varies so drastically from installation to installation for trivial type testing functions, how can I trust the results of profiling using an OS that does not match my target deployment platform?There is no difference in the times when running with APC on or off on both Ubuntu and OS X.
 
Back
Top