1 Star 0 Fork 345

十年砍材 / swoole-src

forked from swoole / swoole-src 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
benchmark.php 677 Bytes
一键复制 编辑 原始数据 按行查看 历史
twosee 提交于 2019-01-07 14:45 . Use Swoole Process.
#!/usr/bin/env php
<?php
$process = new Swoole\Process(function (Swoole\Process $process) {
$http = new Swoole\Http\Server('127.0.0.1', 9501, SWOOLE_BASE);
$http->set(['log_file' => '/dev/null', 'log_level' => SWOOLE_LOG_INFO, 'worker_num' => swoole_cpu_num() * 2]);
$http->on('workerStart', function () use ($process) { $process->write('1'); });
$http->on('request', function (Swoole\Http\Request $request, Swoole\Http\Response $response) {
$response->end('<h1>Hello Swoole!</h1>');
});
$http->start();
});
$process->start();
$process->read(1);
System('ab -c 128 -n 100000 -k http://127.0.0.1:9501/ 2>&1');
Swoole\Process::kill($process->pid);
C
1
https://gitee.com/JackZhang_2016/swoole.git
git@gitee.com:JackZhang_2016/swoole.git
JackZhang_2016
swoole
swoole-src
master

搜索帮助