您的位置:首页 > 编程语言 > PHP开发

laravel5.2、thinkphp5、thinkphp3.2.3性能AB测试

2016-05-17 12:53 579 查看

测试使用同一台机器、同一个数据库,同一个表,发现laravel语法和tp5语法相似度极高,而且性能也差不多,从数据上看tp5性能比laravel高一点点,但还没tp3高

请求5000次,并发200
laravel

Requests per second:    1655.54 [#/sec] (mean)每秒请求数(平均)越大越好
Time per request:       120.807 [ms] (mean)每次并发请求时间越小越好
Time per request:       0.604 [ms] (mean, across all concurrent requests)每次并发请求时间越小越好

thinkphp5

Requests per second:    1697.69 [#/sec] (mean)每秒请求数(平均) 越大越好
Time per request:       117.807 [ms] (mean)每次并发请求时间 越小越好
Time per request:       0.589 [ms] (mean, across all concurrent requests))每次并发请求时间 越小越好

laravel代码

模型

class DocumentArticle extends Model
{
protected $table = 'document_article';
//
}

控制器

class IndexController extends Controller
{
public function index(){

$list =  DocumentArticle::all();

return view('index', ['list' => $list]);
}

}

视图

@foreach ($list as $user)
{{ $user->id }}:{!! $user->content !!}
@endforeach

测试结果

Server Software:        Apache/2.4.17
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /laravel/public
Document Length:        340 bytes

Concurrency Level:      200
Time taken for tests:   0.604 seconds
Complete requests:      1000
Failed requests:        0
Non-2xx responses:      1000
Total transferred:      597000 bytes
HTML transferred:       340000 bytes
Requests per second:    1655.54 [#/sec] (mean)
Time per request:       120.807 [ms] (mean)
Time per request:       0.604 [ms] (mean, across all concurrent requests)
Transfer rate:          965.19 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       1
Processing:    33  107  17.7    113     131
Waiting:       33  107  17.6    113     131
Total:         34  108  17.7    114     131

Percentage of the requests served within a certain time (ms)
50%    114
66%    115
75%    115
80%    116
90%    118
95%    121
98%    124
99%    127
100%    131 (longest request)

thinkphp5代码

模型

class DocumentArticle extends Model
{

}

控制器

class Index extends Controller
{
public function index()
{
$list = DocumentArticle::all();
$this->assign('list',$list);
return $this->fetch('index');
}
}

视图

{volist name="list" id="vo"}
{$vo.id}:{$vo.content}<br/>
{/volist}

测试结果

Server Software:        Apache/2.4.17
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /tp5/public
Document Length:        336 bytes

Concurrency Level:      200
Time taken for tests:   0.589 seconds
Complete requests:      1000
Failed requests:        0
Non-2xx responses:      1000
Total transferred:      589000 bytes
HTML transferred:       336000 bytes
Requests per second:    1697.69 [#/sec] (mean)
Time per request:       117.807 [ms] (mean)
Time per request:       0.589 [ms] (mean, across all concurrent requests)
Transfer rate:          976.51 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       1
Processing:    33  106  17.5    110     132
Waiting:       33  106  17.5    110     132
Total:         34  106  17.5    110     133

Percentage of the requests served within a certain time (ms)
50%    110
66%    115
75%    117
80%    118
90%    120
95%    121
98%    124
99%    127
100%    133 (longest request)

thinkphp3.2.3表现不错

Server Software:        Apache/2.4.17
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /onetk
Document Length:        331 bytes

Concurrency Level:      200
Time taken for tests:   0.528 seconds
Complete requests:      1000
Failed requests:        0
Non-2xx responses:      1000
Total transferred:      579000 bytes
HTML transferred:       331000 bytes
Requests per second:    1893.83 [#/sec] (mean)
Time per request:       105.606 [ms] (mean)
Time per request:       0.528 [ms] (mean, across all concurrent requests)
Transfer rate:          1070.83 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0    0   0.4      0       2
Processing:    27   95  15.5     99     121
Waiting:       27   94  15.5     98     121
Total:         28   95  15.5     99     121

Percentage of the requests served within a certain time (ms)
50%     99
66%    100
75%    100
80%    101
90%    108
95%    112
98%    117
99%    119
100%    121 (longest request)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: