发布时间:2015-05-27 19:21:59作者:知识屋
js出了个nodejs,我们技术老大前段时间发了个技术邮件说php支持多线程,异步,非阻塞 还打着旗号说要灭掉nodejs,官方网站上说swoole的性能已经最少也和nodejs可以媲美了,这个需要用数据说话,周末的时候有空就顺手测试了一下这两个东东!下面是测试报告哈。
首先我用127.0.0.1:8000端口测试swoole, 用127.0.0.1:1337测试nodejs
有图有真相:(稍后传,不会用mac把截图保存!汗!各位看客有谁会的教教我哈!编程都变傻了)
测试环境:
处理器:2.7GHz i7
内存:16GB 1600hz DDR3
系统 MAC OS X
先放测试结果:
1.PHPswoole的测试结果:
~mysql|? ab -n 5000 -c 100 http://127.0.0.1:8000/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 127.0.0.1 (be patient)Completed 500 requestsCompleted 1000 requestsCompleted 1500 requestsCompleted 2000 requestsCompleted 2500 requestsCompleted 3000 requestsCompleted 3500 requestsCompleted 4000 requestsCompleted 4500 requestsCompleted 5000 requestsFinished 5000 requestsServer Software: Server Hostname: 127.0.0.1Server Port: 8000Document Path: /Document Length: 0 bytesConcurrency Level: 100Time taken for tests: 1.411 secondsComplete requests: 5000Failed requests: 0Write errors: 0Total transferred: 55330 bytesHTML transferred: 0 bytesRequests per second: 3543.00 [#/sec] (mean)Time per request: 28.225 [ms] (mean)Time per request: 0.282 [ms] (mean, across all concurrent requests)Transfer rate: 38.29 [Kbytes/sec] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 0 3 1.2 3 7Processing: 17 25 16.7 23 143Waiting: 1 9 12.9 7 136Total: 20 28 16.6 26 143Percentage of the requests served within a certain time (ms) 50% 26 66% 27 75% 27 80% 27 90% 28 95% 29 98% 141 99% 142 100% 143 (longest request)
~mysql|? ab -n 5000 -c 100 http://127.0.0.1:1337/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 127.0.0.1 (be patient)Completed 500 requestsCompleted 1000 requestsCompleted 1500 requestsCompleted 2000 requestsCompleted 2500 requestsCompleted 3000 requestsCompleted 3500 requestsCompleted 4000 requestsCompleted 4500 requestsCompleted 5000 requestsFinished 5000 requestsServer Software: Server Hostname: 127.0.0.1Server Port: 1337Document Path: /Document Length: 12 bytesConcurrency Level: 100Time taken for tests: 1.215 secondsComplete requests: 5000Failed requests: 0Write errors: 0Total transferred: 565000 bytesHTML transferred: 60000 bytesRequests per second: 4116.49 [#/sec] (mean)Time per request: 24.293 [ms] (mean)Time per request: 0.243 [ms] (mean, across all concurrent requests)Transfer rate: 454.26 [Kbytes/sec] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 0 0 0.6 0 5Processing: 2 24 21.0 21 175Waiting: 2 24 20.8 21 174Total: 6 24 20.9 21 175Percentage of the requests served within a certain time (ms) 50% 21 66% 22 75% 23 80% 24 90% 26 95% 32 98% 159 99% 170 100% 175 (longest request)
PHP和nodejs成绩都还不错,关键是Swoole的环境我用了--debug导致有很多命令会输出,暂时有不会改回去,(稍后在公司测试环境重新测试下)
Time taken for tests: 1.411 seconds共耗时
Requests per second: 3543.00 [#/sec] (mean)
nodeJS
Time taken for tests: 1.215 seconds共耗时
Requests per second: 4116.49 [#/sec] (mean)
从测试结果来看,虽然swoole的测试数据稍微逊色了一点,但是这并不影响我对swoole的看法(况且配置可能不是很好),我觉的对于一个C语言编写的PHP,这个已经比我们目前的环境要好的多了。
如何对PHP文件进行加密方法 PHP实现加密的几种方式介绍
php生成圆角图片的方法 电脑中php怎么生成圆角图片教程
用PHP构建一个留言本方法步骤 php怎么实现留言板功能
php中三元运算符用法 php中的三元运算符使用说明
php文件如何怎么打开方式介绍 php文件用什么打开方法
PHP怎么插入数据库方法步骤 php编程怎么导入数据库教程
如何安装PHPstorm并配置方法教程 phpstorm安装后要进行哪些配置
PHP 获取远程文件大小的3种解决方法 如何用PHP获取远程大文件的大小
20个实用PHP实例代码 php接口开发实例代码详细介绍
如何架设PHP服务器方法步骤 怎么搭建php服务器简单教程