发布网友 发布时间:2022-04-29 09:34
共2个回答
懂视网 时间:2022-04-29 13:56
开始测试
增加一个控制器,并在控制器中输入10000次HelloWorld
并发50循环10次:
首先向我们走来的是ThinkPHP,看上去还行
Transactions: 500 hits
Availability: 100.00 %
Elapsed time: 2.81 secs
Data transferred: 52.45 MB
Response time: 0.26 secs
Transaction rate: 177.94 trans/sec
Throughput: 18.67 MB/sec
Concurrency: 47.10
Successful transactions: 500
Failed transactions: 0
Longest transaction: 0.48
Shortest transaction: 0.03
然后是Laravle:
并发200循环10次:
首先是ThinkPHP
Transactions: 1977 hits
Availability: 98.85 %
Elapsed time: 10.03 secs
Data transferred: 207.40 MB
Response time: 0.95 secs
Transaction rate: 197.11 trans/sec
Throughput: 20.68 MB/sec
Concurrency: 187.68
Successful transactions: 1977
Failed transactions: 23
Longest transaction: 1.22
Shortest transaction: 0.02
然后是Laravel
Transactions: 1890 hits
Availability: 94.50 %
Elapsed time: 51.85 secs
Data transferred: 198.27 MB
Response time: 4.88 secs
Transaction rate: 36.45 trans/sec
Throughput: 3.82 MB/sec
Concurrency: 178.00
Successful transactions: 1890
Failed transactions: 110
Longest transaction: 26.01
Shortest transaction: 0.07
没想到在没有优化的情况下,ThinkPHP的速度是最快的,Yii略微多一些,Laravel步履蹒跚的跑完了测试。结果是有些出人意料的,不过上述的测试只代表了开发环境,下面会对框架进行优化,模拟线上环境。
优化框架
ThinkPHP:
APP_DEBUG改为false
Laravel:
APP_DEBUG改为false
php artisan route:cache
php artisan optimize
php artisan config:cache
composer dumpautoload -o
并发200循环10次:
ThinkPHP
Transactions: 1655 hits
Availability: 82.75 %
Elapsed time: 8.21 secs
Data transferred: 173.62 MB
Response time: 0.69 secs
Transaction rate: 201.58 trans/sec
Throughput: 21.15 MB/sec
Concurrency: 139.29
Successful transactions: 1655
Failed transactions: 345
Longest transaction: 7.83
Shortest transaction: 0.00
Laravel:
Transactions: 1520 hits
Availability: 76.00 %
Elapsed time: 34.95 secs
Data transferred: 159.45 MB
Response time: 3.15 secs
Transaction rate: 43.49 trans/sec
Throughput: 4.56 MB/sec
Concurrency: 136.84
Successful transactions: 1520
Failed transactions: 480
Longest transaction: 19.18
Shortest transaction: 0.00
比较奇怪的一点,当框架关掉调试模式后都出现了较多失败的情况。不过明显的看到,Laravel进行简单的优化后,性能大大的提升了,但还是低于其他两个框架。
结论:
ThinkPHP的性能比Laravel高出近四倍。
Gxlcms,大量的免费laravel入门教程,欢迎在线学习!
热心网友 时间:2022-04-29 11:04
thinkphp简单,