首頁 繪圖設計 工作閒聊 比賽活動 美術討論 標籤 圖片
回上頁
php-7.0-mod_php-apache2.4 vs. HHVM performance quick test
Type(Type) 2017/3/12 14:15 (Since 2017/3/12 13:41)

php-7.0-mod_php-apache2.4 vs. HHVM performance quick test




All Test Env is by default, no additional fine tune,
so don't take these test too serious.


Box: Virtual Box @ Intel Core-i7 4-Core
Linux OS: Ubuntu 16.04.02
Kernel: 4.4.0-64 X86_64 SMP


Apache 2.4: Apache/2.4.18, 2016-07-14T12:32:26

PHP: PHP 7.0.15-0ubuntu0.16.04.4, mod_php7

HHVM: HipHop VM 3.18.1 (rel)


Test (1): random & hash test


php7-mod_php faster, 16s(mod_php) vs 23s(hhvm)


代碼:

<?PHP

function prepare_random_source()
{
   $rtn = '';
   for ($i=1; $i<=256; $i++)
   {
      $rtn .= mt_rand( 0, 9 ).'';
   }
   return $rtn;
}   


$loop = 131072 * 2;
$t1 = time();
while($loop-- > 0)
{
   $s1 = prepare_random_source();
   $s2 = sha1(md5($s1));
   $s3 = crc32($s1.$s2.mt_rand( 0, 1048576 ).'-'.time());
   if ($loop % 2)
   {
      $s4 = mt_rand(1, 255) xor mt_rand(1, 255);
   }
}
$t2 = time();

echo $t2 - $t1."\n";

?>

Type(Type) 2017/3/12 14:14

Test (2): String Search & Replace test


php7-mod_php(16 seconds) still faster than hhvm(21 seconds)


代碼:

<?PHP

$orig_str="En Taro Adun, Zeratul.";

$str = '';
for ($i=0; $i<=255; $i++)
{
        $str .= ($i+1).' '.$orig_str."\n";
}


$loop = 131072 * 8;
$ccnt = 0;
$t1 = time();
while ($loop-- > 0)
{
        $b = explode("\n", $str);

        $this_str = $b[($loop % 255)];

        if (strstr($this_str, '3') || strstr($this_str, '11') || strstr($this_str, '17'))
        {
                $t = intval(time());
                $t = ($t / 127);
                $t--;

                $c = str_replace('Adun', $t*$t, $this_str);
                $ccnt++;
        }

}
$t2 = time();

echo $t2 - $t1;

?>

(4,408 views)
[更多討論] 討論區 Windows, Linux, Perl, PHP, C/C++, Driver, Web 理論、應用、硬體、軟體
回上頁

"php-7.0-mod_php-apache2.4 vs. HHVM performance quick test" 傳統頁面(電腦版)

首頁 繪圖設計 工作閒聊 比賽活動 美術討論 標籤 圖片
傳統桌面版 [ 登入/註冊 ]
© Vovo2000.com Mobile Version 小哈手機版 2024