C开发的PHP框架Phalcon性能有多高

3 篇文章 0 订阅

参考网站:http://www.dedecms.com/knowledge/program/php/2012/0827/13423.html

在过去,当开发Web应用程序的时候性能首先是不考虑的,合理的硬件设施能够弥补这个环节。然而当谷歌决定把网站速度纳入到SEO中,性能成为了优先考虑的对象,这就意味着,提高网络性能对一个站点将会有着积极的影响。

下面的一些测试是展示C开发的Phalcon同其他一些PHP开发的框架性能差异,这些对比的软件版本都是已经发布的stable版本。

如何进行基准测试

我们通常情况下创建了一个“Hello World”试图来确定每个框架的最小负载,但许多人不喜欢这样的基准方式,因为实际运用过程中需要更复杂的功能或者结构,这些测试确定每一个框架执行的最小时间。

A controller and a view have been created for each framework. The controller “say” and action “hello”. The action only sends data to the view which displays it (“Hello!”). Using the “ab” benchmark tool we sent 1000 requests using 5 concurrent connections to each framework.

我们的测试环境

系统服务器环境

 

 

  • Operating System: Mac OS X Snow Leopard 10.6.8
  • Web Server: Apache httpd 2.2.21
  • PHP: 5.3.8
  • CPU: 3.06 Ghz Intel Core 2 Duo
  • Main Memory: 4GB 1067 MHz DDR3
  • Hard Drive: 500GB SCSI/SAS HDD

 

php的版本信息

 

../_images/bench-1.png

apache服务器环境

../_images/bench-2.png

apc设置

../_images/bench-3.png

结果

 

Yii (YII_DEBUG=false) Version yii-1.1.10.r3566

 

Yii is a high-performance PHP framework best for developing Web 2.0 applications. The version used for the benchmarks was yii-1.1.10.r3566. We disabled YII_DEBUG to achieve maximum perfomance.

# ab -n 1000 -c 5 http://localhost/bench/yii/index.php?r=say/hello
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
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


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

Document Path:          /bench/yii/index.php?r=say/hello
Document Length:        61 bytes

Concurrency Level:      5
Time taken for tests:   1.311 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      232000 bytes
HTML transferred:       61000 bytes
Requests per second:    762.55 [#/sec] (mean)
Time per request:       6.557 [ms] (mean)
Time per request:       1.311 [ms] (mean, across all concurrent requests)
Transfer rate:          172.76 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.9      0       5
Processing:     2    6   7.0      4      74
Waiting:        0    5   5.7      4      60
Total:          2    6   7.0      5      76
WARNING: The median and mean for the initial connection time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%      5
  66%      5
  75%      7
  80%      7
  90%     10
  95%     16
  98%     29
  99%     48
 100%     76 (longest request)

 

Symfony Version 2.0.11

 

Symfony is another high-performance PHP framework.

# ab -n 1000 -c 5 http://localhost/bench/Symfony/web/app.php/say/hello/
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
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


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

Document Path:          /bench/Symfony/web/app.php/say/hello/
Document Length:        16 bytes

Concurrency Level:      5
Time taken for tests:   8.186 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      270000 bytes
HTML transferred:       16000 bytes
Requests per second:    122.15 [#/sec] (mean)
Time per request:       40.932 [ms] (mean)
Time per request:       8.186 [ms] (mean, across all concurrent requests)
Transfer rate:          32.21 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.7      0      10
Processing:    14   40  40.7     24     345
Waiting:        0   39  40.2     24     345
Total:         14   41  40.8     26     346

Percentage of the requests served within a certain time (ms)
  50%     26
  66%     34
  75%     43
  80%     50
  90%     92
  95%    138
  98%    162
  99%    197
 100%    346 (longest request)

CodeIgniter 2.1.0

 

CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.

# ab -n 1000 -c 5 http://localhost/bench/codeigniter/index.php/say/hello
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
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


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

Document Path:          /bench/codeigniter/index.php/say/hello
Document Length:        16 bytes

Concurrency Level:      5
Time taken for tests:   1.184 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      187000 bytes
HTML transferred:       16000 bytes
Requests per second:    844.63 [#/sec] (mean)
Time per request:       5.920 [ms] (mean)
Time per request:       1.184 [ms] (mean, across all concurrent requests)
Transfer rate:          154.24 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.7      0       5
Processing:     2    5  11.0      4     148
Waiting:        0    5  10.8      4     148
Total:          2    6  10.9      4     148

Percentage of the requests served within a certain time (ms)
  50%      4
  66%      4
  75%      5
  80%      6
  90%      8
  95%     12
  98%     24
  99%     38
 100%    148 (longest request)

Kohana 3.2.0

 

Kohana is an elegant HMVC PHP5 framework that provides a rich set of components for building web applications.

# ab -n 1000 -c 5 http://localhost/bench/kohana/index.php/say/hello
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
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


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

Document Path:          /bench/kohana/index.php/say/hello
Document Length:        15 bytes

Concurrency Level:      5
Time taken for tests:   1.603 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      186000 bytes
HTML transferred:       15000 bytes
Requests per second:    623.77 [#/sec] (mean)
Time per request:       8.016 [ms] (mean)
Time per request:       1.603 [ms] (mean, across all concurrent requests)
Transfer rate:          113.30 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.9      0       5
Processing:     2    7  22.4      5     317
Waiting:        0    7  22.3      4     317
Total:          2    8  22.3      5     318

Percentage of the requests served within a certain time (ms)
  50%      5
  66%      5
  75%      6
  80%      7
  90%     10
  95%     17
  98%     33
  99%     46
 100%    318 (longest request)

Fuel 1.2

 

FuelPHP is a simple, flexible, community driven PHP 5.3 web framework based on the best ideas of other frameworks with a fresh start.

# ab -n 1000 -c 5 http://localhost/bench/fuel/say/hello
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
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


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

Document Path:          /bench/fuel/say/hello
Document Length:        16 bytes

Concurrency Level:      5
Time taken for tests:   1.771 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      187000 bytes
HTML transferred:       16000 bytes
Requests per second:    564.49 [#/sec] (mean)
Time per request:       8.857 [ms] (mean)
Time per request:       1.771 [ms] (mean, across all concurrent requests)
Transfer rate:          103.09 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.0      0       6
Processing:     3    8   9.2      6      80
Waiting:        0    7   7.2      5      80
Total:          3    9   9.2      6      81

Percentage of the requests served within a certain time (ms)
  50%      6
  66%      7
  75%      9
  80%     10
  90%     16
  95%     23
  98%     43
  99%     59
 100%     81 (longest request)

Cake 2.1.3

 

CakePHP makes building web applications simpler, faster and require less code. Unlike others, we are measuring only 10 requests of 1000, if you know how to improve this results please write us.

# ab -n 10 -c 5 http://localhost/bench/cake/say/hello
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).....done


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

Document Path:          /bench/cake/say/hello
Document Length:        16 bytes

Concurrency Level:      5
Time taken for tests:   30.051 seconds
Complete requests:      10
Failed requests:        0
Write errors:           0
Total transferred:      1680 bytes
HTML transferred:       160 bytes
Requests per second:    0.33 [#/sec] (mean)
Time per request:       15025.635 [ms] (mean)
Time per request:       3005.127 [ms] (mean, across all concurrent requests)
Transfer rate:          0.05 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   3.6      0      11
Processing: 15009 15020   9.8  15019   15040
Waiting:        9   21   7.9     25      33
Total:      15009 15022   8.9  15021   15040

Percentage of the requests served within a certain time (ms)
  50%  15021
  66%  15024
  75%  15024
  80%  15032
  90%  15040
  95%  15040
  98%  15040
  99%  15040
 100%  15040 (longest request)

Phalcon Version 0.3.5

# ab -n 1000 -c 5 http://localhost/bench/phalcon/?_url=say/hello
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
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


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

Document Path:          /bench/phalcon/?_url=say/hello
Document Length:        16 bytes

Concurrency Level:      5
Time taken for tests:   0.385 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      187000 bytes
HTML transferred:       16000 bytes
Requests per second:    2599.46 [#/sec] (mean)
Time per request:       1.923 [ms] (mean)
Time per request:       0.385 [ms] (mean, across all concurrent requests)
Transfer rate:          474.71 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.3      0       3
Processing:     1    2   1.9      1      43
Waiting:        0    1   1.8      1      43
Total:          1    2   1.9      2      43

Percentage of the requests served within a certain time (ms)
  50%      2
  66%      2
  75%      2
  80%      2
  90%      3
  95%      4
  98%      5
  99%      9
 100%     43 (longest request)

图像结果

结论

编译后的Phalcon性能表现优于其他传统框架


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值