Why HHVM execution time is too much as comparision of PHP for some code?

215 Views Asked by At

I have comapred PHP execution time VS HHVM execution time for some codes taken from http://phpbench.com/ . Except some function in all way HHVM is faster than PHP. Here are some codes in which php execution time is less than HHVM execution time . Can anyone tell why this happens for some codes ?

 1 - Use Single dimension array

<?php
function Test4_1() {
global $x;
$t = microtime(true);
$size = count($x);
$i = 0;
while($i < 1000) {
$alias = $aSingleDimArray[$i];
 ++$i;
}
return (microtime(true) - $t);
}
$returnData = Test4_1();
$microtime = ($returnData * 1000000);
echo "execution time is ".$microtime." micro seconds.";
?>

 2 - Use of multi dimension array


<?php
function Test4_3() {
 global $x;
 $t = microtime(true);
 while($i < 1000) {
 $alias = $aMultiDimArray[$i]["aaaaa"]["aaaaaaaaaa"];
 ++$i;
 }
 return (microtime(true) - $t);
 }
 $returnData = Test4_3();
 $microtime = ($returnData * 1000000);
 echo "execution time is ".$microtime." micro seconds.";

3 - Use of very multi dimension array
 <?php
 function Test4_5() {
  global $x;
 $t = microtime(true);
 while($i < 1000) {
 $alias = $veryMultiDimArray[$i]["a"]["aa"]["aaa"]["aaaa"]["aaaaa"];
 ++$i;
 }
 return (microtime(true) - $t);
 }
 $returnData = Test4_5();
 $microtime = ($returnData * 1000000);
  echo "execution time is ".$microtime." micro seconds.";
 ?>

For Some code i found HHVM execution time is 16.736 microseconds while PHP execution   time is (unexpected) 41515.111 microseconds.

Here is the code-

<?php
global $x;
$i = 0;
$tmp = '';
while($i < 10000) {
$tmp .= 'a';
++$i;
}
$x = array_fill(5, 1000, $tmp);
 unset($i, $tmp);
function Test3_4() {
global $x;
$t = microtime(true);
for ($i=0; $i return (microtime(true) - $t);
}
function Test3_End() {
global $x;
unset($x);
}
Test3_End();
$returnData = Test3_4();
$microtime = ($returnData * 1000000);
echo "execution time is ".$microtime." micro seconds.";
?>
0

There are 0 best solutions below