PHP HipHop 的 apache 基准测试

发布于 2024-11-19 07:50:26 字数 3648 浏览 2 评论 0原文

最近,我使用 Apache Benchmark (ab) 对 PHP 的 HipHop 进行了基准测试。

我预计 HipHop for PHP 的结果比普通 apache2 Web 服务器运行得更快,但结果却相反。

我使用此脚本来测试服务器,

<?php
  $i=0;
  while($i < 1000000){
    echo 'Welcome to HipHop for PHP<br />';
    $i++;
  }
?>

并使用此 ab 命令进行基准测试:

ab -n 500 -c 5 [URL]

我使用此命令进行编译:

hphp/hphp hiphop1.php -k 1 -l 3

apache2 服务器的基准测试结果:

kiddo@kiddo-VirtualBox:~/dev/hiphop-php/doc$ ab -n 500 -c 5 http://localhost/hiphop1.php
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests


Server Software:        Apache/2.2.16
Server Hostname:        localhost
Server Port:            80

Document Path:          /hiphop1.php
Document Length:        31000000 bytes

Concurrency Level:      5
Time taken for tests:   71.024 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      15500095500 bytes
HTML transferred:       15500000000 bytes
Requests per second:    7.04 [#/sec] (mean)
Time per request:       710.240 [ms] (mean)
Time per request:       142.048 [ms] (mean, across all concurrent requests)
Transfer rate:          213122.37 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.9      0      19
Processing:   505  708  61.1    694     960
Waiting:        0    0   3.3      0      67
Total:        505  708  61.1    695     960

Percentage of the requests served within a certain time (ms)
  50%    695
  66%    714
  75%    729
  80%    736
  90%    781
  95%    857
  98%    898
  99%    938
 100%    960 (longest request)

以及 的基准测试HipHop for PHP:

kiddo@kiddo-VirtualBox:~/dev/hiphop-php/doc$ ab -n 500 -c 5 http://localhost:8080/hiphop1.php
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests


Server Software:        
Server Hostname:        localhost
Server Port:            8080

Document Path:          /hiphop1.php
Document Length:        31000000 bytes

Concurrency Level:      5
Time taken for tests:   294.546 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      15500052500 bytes
HTML transferred:       15500000000 bytes
Requests per second:    1.70 [#/sec] (mean)
Time per request:       2945.455 [ms] (mean)
Time per request:       589.091 [ms] (mean, across all concurrent requests)
Transfer rate:          51390.26 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.6      0      20
Processing:  1515 2941 579.7   2919    4734
Waiting:     1452 2626 532.5   2609    4135
Total:       1515 2941 579.7   2919    4734

Percentage of the requests served within a certain time (ms)
  50%   2919
  66%   3147
  75%   3334
  80%   3448
  90%   3704
  95%   3937
  98%   4223
  99%   4394
 100%   4734 (longest request)

问题是,为什么 HipHop 在我的基准测试中运行速度较慢?

脚本测试有什么问题吗?

Recently I've done a benchmark on HipHop for PHP with Apache Benchmark (ab).

I expected the result HipHop for PHP run faster than normal apache2 web server, but it turned out the other way.

I use this script to test the server,

<?php
  $i=0;
  while($i < 1000000){
    echo 'Welcome to HipHop for PHP<br />';
    $i++;
  }
?>

and I use this ab command to benchmark:

ab -n 500 -c 5 [URL]

and I use this command to compile:

hphp/hphp hiphop1.php -k 1 -l 3

The benchmark result for the apache2 server:

kiddo@kiddo-VirtualBox:~/dev/hiphop-php/doc$ ab -n 500 -c 5 http://localhost/hiphop1.php
This is ApacheBench, Version 2.3 <$Revision: 655654 
gt;
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests


Server Software:        Apache/2.2.16
Server Hostname:        localhost
Server Port:            80

Document Path:          /hiphop1.php
Document Length:        31000000 bytes

Concurrency Level:      5
Time taken for tests:   71.024 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      15500095500 bytes
HTML transferred:       15500000000 bytes
Requests per second:    7.04 [#/sec] (mean)
Time per request:       710.240 [ms] (mean)
Time per request:       142.048 [ms] (mean, across all concurrent requests)
Transfer rate:          213122.37 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.9      0      19
Processing:   505  708  61.1    694     960
Waiting:        0    0   3.3      0      67
Total:        505  708  61.1    695     960

Percentage of the requests served within a certain time (ms)
  50%    695
  66%    714
  75%    729
  80%    736
  90%    781
  95%    857
  98%    898
  99%    938
 100%    960 (longest request)

and the benchmark for HipHop for PHP:

kiddo@kiddo-VirtualBox:~/dev/hiphop-php/doc$ ab -n 500 -c 5 http://localhost:8080/hiphop1.php
This is ApacheBench, Version 2.3 <$Revision: 655654 
gt;
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests


Server Software:        
Server Hostname:        localhost
Server Port:            8080

Document Path:          /hiphop1.php
Document Length:        31000000 bytes

Concurrency Level:      5
Time taken for tests:   294.546 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      15500052500 bytes
HTML transferred:       15500000000 bytes
Requests per second:    1.70 [#/sec] (mean)
Time per request:       2945.455 [ms] (mean)
Time per request:       589.091 [ms] (mean, across all concurrent requests)
Transfer rate:          51390.26 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.6      0      20
Processing:  1515 2941 579.7   2919    4734
Waiting:     1452 2626 532.5   2609    4135
Total:       1515 2941 579.7   2919    4734

Percentage of the requests served within a certain time (ms)
  50%   2919
  66%   3147
  75%   3334
  80%   3448
  90%   3704
  95%   3937
  98%   4223
  99%   4394
 100%   4734 (longest request)

The question is, why HipHop run slower in my benchmark?

is there anything wrong with the script test?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍白女子 2024-11-26 07:50:26

PHP hip-hop 可以加快 PHP 代码执行速度,这是一个常见的误解。不一定。 Facebook 开发它是因为他们的整个平台构建在几个 PHP 文件中,而这些文件执行得非常频繁并且非常庞大,以至于使用纯 PHP 效率很低。

使用 Hip-Hop 只是在 PHP 的执行中添加一个步骤,您永远不应该将 PHP Hip-Hop 用于这样的“简单”代码。

<块引用>

此外,PHP 还执行一些在 C+ 中通过 PHP 脚本本机执行的函数。

It is a common misconception that PHP hip-hop speeds up PHP code execution. It doesn't necessarily. Facebook developed it because their whole platform is built into a couple of PHP files, and those files are executed so frequently and are so massive that it would be inefficient to use pure PHP.

using Hip-Hop is just adding a step to the execution of PHP, you should never use PHP Hip-Hop for 'Simple' Code like that.

Also, PHP executes some functions that are natively executed in C+ with their PHP script.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文