- Code: Select all
<?php
$start = microtime(true);
for ($i = 0; $i < 1E6; $i++) {
hash('sha512', 'the quick brown fox jumps over the lazy dog');
}
echo ((microtime(true) - $start) * 1000).' ms'.PHP_EOL;
?>
So I run this script on three different PHP builds: (1) a MAMP build, (2) OSX's latest build, (3) XAMPP 1.0.1, and (4) one Linux build in a VM.
- Code: Select all
# 1. PHP 5.2.5 (cli) (built: Nov 29 2007 09:31:38)
$ time /Applications/MAMP/bin/php5/bin/php ~/test.php
real 0m7.013s
user 0m6.831s
sys 0m0.069s
# 2. PHP 5.2.8 (cli) (built: Feb 5 2009 21:21:13)
$ time php test.php
real 0m6.708s
user 0m6.419s
sys 0m0.067s
# 3. PHP 5.2.9 (cli) (built: Apr 12 2009 21:47:42)
$ time /Applications/XAMPP/xamppfiles/bin/php test.php
real 0m9.688s
user 0m9.363s
sys 0m0.106s
# 4. PHP 5.2.10 with Suhosin-Patch 0.9.7 (cli) (built: Jul 14 2009 11:23:14)
$ time php test.php
real 0m1.734s
user 0m1.540s
sys 0m0.010s
Notice how slowly the XAMPP build is executing? It deviates quite a bit off from the native OSX build and MAMP. Does anyone have any idea why this is happening?