I was trying to do some benchmarks of php 5.5 vs HHVM and was getting some pretty good results with hhvm. However the performance of bubble sort on HHVM is pretty bad. I am guessing it has something to do with arrays. In the below example when q=1000 hhvm is almost 5x worse than php 5.5. Since in both case since the test was run so many times I don't believe warm up time should be an issue. In both cases they are being fastcgi mode. In the case where q=1000 php5.5 took about 200ms to serve the page vs almost 1000ms for hhvm. I tried using splfixedclass, but its performance on hhvm was pretty bad too. Is there a special class or some special options that will improve array performance in hhvm?
I put an explanation of what exactly I did here: http://letschat.info/php-5-5-vs-hhvm-vs-node-js-benchmark-part-2/
$starttime = microtime(true);
if($_GET['q']!=""){
$count = $_GET['q'];
} else {
$count = 100;
}
function getRandom(){
$random = array();
global $count;
for($i=0;$i<$count;$i++){
$random[]=rand(1,100);
}
return $random;
}
$array = getRandom();
for($i=0;$i<10;$i++) {
#$i=0;
//while ($i<$a) {
$a = count($array);
$b=$a-1;
for($j=0; $j < $a; $j++){
for ($k=0;$k<$b;$k++) {
if ($array[$k+1] < $array[$k]) {
$t = $array[$k];
$array[$k] = $array[$k+1];
$array[$k+1] = $t;
}
}
//++$i;
}
$array[$count/2]=rand(1,100);
}
print_r($array);
echo microtime(true) - $starttime;
One problem and one possible problem:
-v Eval.Jit=true
. We disable JITting for scripts since they usually don't run a long time and the warm-up cost is more than the runtime cost..
function main() {
// Do everything
}
main();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With