自己动手ab测了个ThinkPHP与CodeIgniter框架性能对比

PHP环境:Apache 2.4.10 + PHP 5.4.36

同样php输出代码

echo ‘Hello Qzzm!‘;

以下列出分别测试结果

一、CodeIgniter 2.2

This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking a.shy.pw (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software: Apache/2.4.10
Server Hostname: a.shy.pw
Server Port: 80

Document Path: /index.php
Document Length: 11 bytes

Concurrency Level: 100
Time taken for tests: 23.541 seconds   #全部请 求完成耗时
Complete requests: 10000
Failed requests: 0
Total transferred: 2150000 bytes
HTML transferred: 110000 bytes
Requests per second: 424.80 [#/sec] (mean)
Time per request: 235.407 [ms] (mean)  #每次并发请求时间(所有并发)
Time per request: 2.354 [ms] (mean, across all concurrent requests)  #每一请求时间(并发平均) 
Transfer rate: 89.19 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 2
Processing: 20 235 191.6 204 1534
Waiting: 20 234 191.6 204 1533
Total: 21 235 191.6 204 1534

Percentage of the requests served within a certain time (ms)
50% 204
66% 211
75% 217
80% 220
90% 234
95% 262
98% 1235
99% 1376
100% 1534 (longest request)

二、Thinkphp 3.2.3开启Debug模式

This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking b.shy.pw (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
apr_pollset_poll: The timeout specified has expired (70007)
Total of 9997 requests completed

三、Thinkphp 3.2.3 不开启Debug模式也就是 正式发布的模式

This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking b.shy.pw (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software: Apache/2.4.10
Server Hostname: b.shy.pw
Server Port: 80

Document Path: /index.php
Document Length: 11 bytes

Concurrency Level: 100
Time taken for tests: 205.808 seconds  #全部请 求完成耗时
Complete requests: 10000
Failed requests: 9
(Connect: 0, Receive: 0, Length: 9, Exceptions: 0)
Total transferred: 4096310 bytes
HTML transferred: 109901 bytes
Requests per second: 48.59 [#/sec] (mean)
Time per request: 2058.080 [ms] (mean)  #每次并发请求时间(所有并发)
Time per request: 20.581 [ms] (mean, across all concurrent requests)  #每一请求时间(并发平均) 
Transfer rate: 19.44 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 20
Processing: 823 2055 2623.9 1863 123212
Waiting: 0 1994 1170.4 1863 14484
Total: 823 2055 2623.9 1863 123212

Percentage of the requests served within a certain time (ms)
50% 1863
66% 1905
75% 1930
80% 1955
90% 2003
95% 2059
98% 4747
99% 12857
100% 123212 (longest request)

四、纯PHP模式,无框架

This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking a.shy.pw (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests

Server Software: Apache/2.4.10
Server Hostname: a.shy.pw
Server Port: 80

Document Path: /index1.php
Document Length: 11 bytes

Concurrency Level: 100
Time taken for tests: 6.312 seconds   #全部请 求完成耗时

Complete requests: 10000
Failed requests: 0
Total transferred: 2150000 bytes
HTML transferred: 110000 bytes
Requests per second: 1584.20 [#/sec] (mean)
Time per request: 63.123 [ms] (mean)  #每次并发请求时间(所有并发)
Time per request: 0.631 [ms] (mean, across all concurrent requests)  #每一请求时间(并发平均)
Transfer rate: 332.62 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 1
Processing: 1 63 275.7 15 1751
Waiting: 0 59 275.7 11 1743
Total: 1 63 275.7 15 1751

Percentage of the requests served within a certain time (ms)
50% 15
66% 16
75% 16
80% 16
90% 16
95% 17
98% 1596
99% 1659
100% 1751 (longest request)

分析得图表:

  全部请求完成耗时 每次并发请求时间(所有并发) 每一请求时间(并发平均) 
纯php无框架 6.312 秒 63.123 毫秒 0.631 毫秒
CodeIgniter 2.2 23.541 秒 235.407 毫秒 2.354 毫秒
ThinkPHP 3.2.3 205.808 秒 2058.080 毫秒 20.581 毫秒
ThinkPHP 3.2.3 Debug - - -

CodeIgniter完胜ThinkPHP,另外从下面的图中可以看到Laravel框架性能也高与CodeIgniter

不过考虑到虚拟主机兼容性和中文开发文档来说 CodeIgniter和Thinkphp还是比较实用

CodeIgniter php版本≥5.2

ThinkPHP 3.2.3   php版本≥5.3

Laravel 新一点的版本都是  php版本≥5.4

最后发一个框架性能图片 外国测试的,机器配置不详,好像是  ?分钟内的请求次数    用问号表示不知道几分钟,估计是1分钟

yaf 扩展式框架最快

结束

时间: 2024-12-14 02:42:30

自己动手ab测了个ThinkPHP与CodeIgniter框架性能对比的相关文章

ThinkPHP第二课 框架MVC目录和URL访问方式

第二课 框架MVC目录和URL访问方式 1.说明: ThinkPHP是基于MVC的框架,认识框架目录将更好的实现分层,掌握ThinkPHP.URL访问就是访问框架的控制器(MVC中的C),共有四种方式,框架中的C起到分模块的作用. url的4种访问方式: 1.PATHINFO 模式 -- 重点!!!!!! http://域名/项目名/入口文件/模块名/方法名/键1/值1/键2/值2 2.普通模式 http://域名/项目名/入口文件?m=模块名&a=方法名&键1=值1&键2=值2

Thinkphp入门三—框架模板、变量(47)

原文:Thinkphp入门三-框架模板.变量(47) [在控制器调用模板] display()   调用当前操作名称的模板 display(‘名字’)  调用指定名字的模板文件 控制器调用模板四种方式: [在控制器给模板传递变量] 在smarty里边给模板传递变量信息 $smarty -> assign(变量名称,值); 在tp框架里边同样适用assign()给模板传递变量信息 ThinkPHP的模板引擎的左右标记: ThinkPHP/Lib/ Behavior/ ParseTemplateBe

ThinkPHP运算符 与 SQL运算符 对比表

ThinkPHP运算符 与 SQL运算符 对比表 TP运算符 SQL运算符 样例 实际查询条件 eq = $map['id'] = array('eq',100); 等效于:$map['id'] = 100; neq != $map['id'] = array('neq',100); id != 100 gt > $map['id'] = array('gt',100); id > 100 egt >= $map['id'] = array('egt',100); id >= 10

小测几种python web server的性能

http://blog.csdn.net/raptor/article/details/8038476 因为换了nginx就不再使用mod_wsgi来跑web.py应用了,现在用的是gevent-wsgi,效果还不错.但还是想试试别的,比如传说中超级猛的meinheld什么的. 软硬件环境 硬件: 一台04年初购置的IBM X235服务器,CPU为Xeon 2.4G两颗,内存1G,100M网卡. 软件: Ubuntu Server 10.04 LTSApache 2.2.14Nginx 0.7.

使用ThinkPHP开发中MySQL性能优化的最佳21条经验

使用ThinkPHP开发中MySQL性能优化的最佳21条经验讲解,目前,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我 们程序员需要去关注的事情.当我们去设计数据库表结构,对操作数据库时(尤其是查表时的SQL语句),我们都需要注意数据操作的性能.这里,我们不会讲过 多的SQL语句的优化,而只是针对MySQL这一Web应用最多的数据库.希望下面的这些优化技巧对你有用. 1. 为查询缓存优化你的查询大多数的MySQ

traefik 与 rancher 集群自带haproxy 压测性能对比

ab性能指标 在进行性能测试过程中有几个指标比较重要: 1.吞吐率(Requests per second) 服务器并发处理能力的量化描述,单位是reqs/s,指的是在某个并发用户数下单位时间内处理的请求数.某个并发用户数下单位时间内能处理的最大请求数,称之为最大吞吐率. 记住:吞吐率是基于并发用户数的.这句话代表了两个含义: a.吞吐率和并发用户数相关 b.不同的并发用户数下,吞吐率一般是不同的 计算公式:总请求数/处理完成这些请求数所花费的时间,即 Request per second=Co

自己动手设计并实现一个linux嵌入式UI框架(设计)

看了"自己动手设计并实现一个linux嵌入式UI框架"显然没有尽兴,因为还没有看到庐山真面目,那我今天继续,先来说说,我用到了哪些知识背景.如:C语言基础知识,尤其是指针.函数指针.内存分布,linux 基础知识.如消息队列.framebuffer.多线程.多线程同步.等,数据结构.算法(如链表.队列等),window .netframework 框架设计思想,设计模式如 mvc.观察者.单例.工厂等.知识点有点多,每个知识点有机的组合在一起,形成了一个知识网,构成了一个系统.以上提到

(亲测)nginx解决thinkphp中pathinfo的问题

找到nginx配置文件中的location ~ \.php$ 去掉后面的"$" 在中括弧里的最下面添加: fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 加号的代码如下面: location ~ \.php {         

thinkphp5 yii2 laravel5.1 框架性能压测对比图

nginx+php7环境,opcache已经开启,每测试一个框架都重启服务器并且预热访问三次,压测工具ab.exe. laravel,thinkphp,yii都已关闭debug,该做的优化命令都搞了,它们输出的view都是相同的,不要怀疑哥的水平. 下面上图: 一.原生php 二.thinkphp5 三.yii2 四.laravel5.1 ps:勿喷. 点击下载自动压测脚本 下载后把后缀 .sh 去掉,此脚本用php编写而成,所以必须要php.exe解析. 本人qq群也有许多的技术文档,希望可以