iT邦幫忙

0

PHP coroutine 的問題

  • 分享至 

  • xImage

請問各位大大,最近在練習 PHP swoole framework => Hyperf
利用 Apache tool (ab) 想測試併發的結果,但發現在協程內的 sleep() 都沒反應,不知道是寫法哪裡有問題

public function test()
{
    go(function () {
        sleep(5);
    });
    go(function () {
        sleep(10);
    });
    go(function () {
       sleep(3);
    });
}

測試

ab -c 2 -n 2 http://localhost:9501/test

結果

Benchmarking localhost (be patient).....done


Server Software:        Hyperf
Server Hostname:        localhost
Server Port:            9501

Document Path:          /test
Document Length:        1 bytes

Concurrency Level:      2
Time taken for tests:   0.005 seconds
Complete requests:      2
Failed requests:        0
Total transferred:      274 bytes
HTML transferred:       2 bytes
Requests per second:    409.25 [#/sec] (mean)
Time per request:       4.887 [ms] (mean)
Time per request:       2.443 [ms] (mean, across all concurrent requests)
Transfer rate:          54.75 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     5    5   0.0      5       5
Waiting:        5    5   0.0      5       5
Total:          5    5   0.0      5       5

Percentage of the requests served within a certain time (ms)
  50%      5
  66%      5
  75%      5
  80%      5
  90%      5
  95%      5
  98%      5
  99%      5
 100%      5 (longest request)
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答