基于hiphopforphp的apache基准测试

基于hiphopforphp的apache基准测试,php,for-loop,hiphop,Php,For Loop,Hiphop,最近我用ApacheBenchmark(ab)在HipHopforPHP上做了一个基准测试 我期望HipHop for PHP的运行速度比普通apache2 web服务器更快,但结果却是相反 我用这个脚本来测试服务器 <?php $i=0; while($i < 1000000){ echo 'Welcome to HipHop for PHP<br />'; $i++; } ?> 我使用这个命令来编译: hphp/hphphiphop

最近我用ApacheBenchmark(ab)在HipHopforPHP上做了一个基准测试

我期望HipHop for PHP的运行速度比普通apache2 web服务器更快,但结果却是相反

我用这个脚本来测试服务器

<?php
  $i=0;
  while($i < 1000000){
    echo 'Welcome to HipHop for PHP<br />';
    $i++;
  }
?>
我使用这个命令来编译:

hphp/hphphiphop1.php-k1-l3

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)
kiddo@kiddo-VirtualBox:~/dev/hiphop php/doc$ab-n500-c5http://localhost/hiphop1.php
这是ApacheBench,版本2.3
版权1996亚当·特维斯,宙斯科技有限公司,http://www.zeustech.net/
授权给Apache软件基金会,http://www.apache.org/
对本地主机进行基准测试(耐心等待)
完成100个请求
已完成200个请求
已完成300个请求
已完成400个请求
完成了500个请求
完成了500个请求
服务器软件:Apache/2.2.16
服务器主机名:localhost
服务器端口:80
文档路径:/hiphop1.php
文件长度:31000000字节
并发级别:5
测试时间:71.024秒
完成申请:500
失败的请求:0
写入错误:0
传输总量:15500095500字节
传输的HTML:15500000000字节
每秒请求数:7.04[#秒](平均值)
每次请求的时间:710.240[ms](平均值)
每个请求的时间:142.048[ms](所有并发请求的平均时间)
传输速率:收到213122.37[千字节/秒]
连接时间(毫秒)
最小平均值[+/-sd]最大中值
连接:0.9 0 19
处理:50570861.1694960
候补人数:03.3067
总数:50570861.1695960
在特定时间内服务的请求百分比(毫秒)
50%    695
66%    714
75%    729
80%    736
90%    781
95%    857
98%    898
99%    938
100%960(最长请求)
以及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)
kiddo@kiddo-VirtualBox:~/dev/hiphop php/doc$ab-n500-c5http://localhost:8080/hiphop1.php
这是ApacheBench,版本2.3
版权1996亚当·特维斯,宙斯科技有限公司,http://www.zeustech.net/
授权给Apache软件基金会,http://www.apache.org/
对本地主机进行基准测试(耐心等待)
完成100个请求
已完成200个请求
已完成300个请求
已完成400个请求
完成了500个请求
完成了500个请求
服务器软件:
服务器主机名:localhost
服务器端口:8080
文档路径:/hiphop1.php
文件长度:31000000字节
并发级别:5
测试时间:294.546秒
完成申请:500
失败的请求:0
写入错误:0
传输总量:15500052500字节
传输的HTML:15500000000字节
每秒请求数:1.70[#秒](平均值)
每次请求的时间:2945.455[ms](平均值)
每个请求的时间:589.091[ms](所有并发请求的平均时间)
传输速率:接收到51390.26[千字节/秒]
连接时间(毫秒)
最小平均值[+/-sd]最大中值
连接:0 1.6 0 20
处理:15152941579.729194734
等候电话:1452626532.526094135
总数:15152941579.729194734
在特定时间内服务的请求百分比(毫秒)
50%   2919
66%   3147
75%   3334
80%   3448
90%   3704
95%   3937
98%   4223
99%   4394
100%4734(最长请求)
问题是,为什么HipHop在我的基准测试中运行得较慢


脚本测试有什么问题吗?

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

使用HipHop只是为PHP的执行添加了一个步骤,您不应该将PHP HipHop用于像这样的“简单”代码

此外,PHP还执行一些本机在C+中使用PHP脚本执行的函数


服务器(尤其是输出缓冲区)的配置可能有所不同。如果缓冲区太小,则需要更多的输入/输出操作。您的测试代码与典型的web应用工作负载相差甚远。现代web应用程序将执行大量对象实例化、数据库IO、用户输入处理等操作。您测试的所有代码都是循环和文本输出。在典型的现实世界中,hiphop很可能会更快,但在一两个非常特殊的情况下,hiphop会更慢?特别是PHP的HipHop?我不知道如何为基准测试web服务器制作测试用例。通过使用php官方开发库中的bench.php,我得到了想要的结果。我使用ab进行基准测试,但我只得到执行时间。如何获得cpu和内存使用率?您可以通过脚本获得cpu负载
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)