ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
# 附录:框架性能报告 ## 服务器基准 系统:Deepin 15.3 Ubuntun内核 CPU:Inter I3 4核 内存:8G ![](https://box.kancloud.cn/65dd362946a19ecbeea2728d5cad1031_409x289.png) ## Http请求ab压测数据 ab和服务器在同一物理机上 ```php /** * http测试 */ public function http_test() { $this->http_output->end('helloworld', false); } ``` ``` ab -c100 -n1000000 -k http://localhost:8081/TestController/test ``` ![](https://box.kancloud.cn/a4364e8277b40410ab46f56cb14e1e23_608x722.png) ## Http请求Redis压测数据 ### 单一请求 ```php /** * http redis 测试 */ public function http_redis() { $value = $this->redis_pool->getCoroutine()->get('test'); $this->http_output->end(1, false); } /** * http 同步redis 测试 */ public function http_aredis() { $value = get_instance()->getRedis()->get('test'); $this->http_output->end(1, false); } ``` 测试协程方法 ``` ab -c100 -n100000 -k http://localhost:8081/TestController/redis ``` ![](https://box.kancloud.cn/9dd24a4c8b639cf65819e2aeb609ad56_672x357.png) 测试同步方法 ``` ab -c100 -n100000 -k http://localhost:8081/TestController/aredis ``` ![](https://box.kancloud.cn/54c4902c4fb50b3b98cefc238cb77a64_633x366.png) 协程方式比同步方式更加快速 ### 多数请求 ```php /** * http redis 测试 */ public function http_redis() { $value = $this->redis_pool->getCoroutine()->get('test'); $value1 = $this->redis_pool->getCoroutine()->get('test1'); $value2 = $this->redis_pool->getCoroutine()->get('test2'); $value3 = $this->redis_pool->getCoroutine()->get('test3'); yield $value; yield $value1; yield $value2; yield $value3; $this->http_output->end(1, false); } /** * http 同步redis 测试 */ public function http_aredis() { $value = get_instance()->getRedis()->get('test'); $value1 = get_instance()->getRedis()->get('test1'); $value2 = get_instance()->getRedis()->get('test2'); $value3 = get_instance()->getRedis()->get('test3'); $this->http_output->end(1, false); } ``` 测试协程方法 ``` ab -c100 -n100000 -k http://localhost:8081/TestController/redis ``` ![](https://box.kancloud.cn/050b222a1dc668e686c7dab28ffd338b_655x359.png) 测试同步方法 ``` ab -c100 -n100000 -k http://localhost:8081/TestController/aredis ``` ![](https://box.kancloud.cn/ef7bc68cd4292483b7824470b7c5b782_693x361.png) 同样协程的方法更加快速。 ## Http请求的JMeter聚合报告 测试访问的路径为TestController/test 配置: ![](https://box.kancloud.cn/a618d3e4c3d8634745157cb140493809_770x312.png) ![](https://box.kancloud.cn/53ba476d01672cdd6737e20702519257_779x278.png) 聚合报告: ![](https://box.kancloud.cn/d14d9524bede65d3783d4e89b66e051d_925x208.png) ## Tcp请求的JMeter聚合报告 Jmeter的Tcp测试需要改下服务器的默认配置,在\(>1.7版本后\)config中可以配置probuf\_set. ```php $config['server']['probuf_set'] = [ 'open_length_check' => 1, 'package_length_type' => 'n', 'package_length_offset' => 0, //第N个字节是包长度的值 'package_body_offset' => 2, //第几个字节开始计算长度 'package_max_length' => 2000000, //协议最大长度) ]; ``` Tcp取样器的配置 ![](https://box.kancloud.cn/f60a395131b49814eb3fa49d7741f042_865x377.png) 由于配置的是二进制数据,所以发送的文本是HEX模式。 实际上发送的协议体内容为: ``` {"controller_name":"TestController","method_name":"test","data":"helloworld"} ``` 调用的方法是 ```php /** * tcp的测试 */ public function test() { $this->send($this->client_data->data,false); } ``` 聚合报告 ![](https://box.kancloud.cn/c2e460612893b4e3c14cbf73cc122958_1188x202.png)