1 Star 0 Fork 345

xzut / swoole-src

forked from swoole / swoole-src 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
benchmark.php 678 Bytes
一键复制 编辑 原始数据 按行查看 历史
twosee 提交于 2018-11-10 17:16 . Add automatic benchmark script.
#!/usr/bin/env php
<?php
$wait = new Swoole\Atomic(0);
$pid = pcntl_fork();
if ($pid === 0) {
$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 ($wait) { $wait->set(1); });
$http->on('request', function (Swoole\Http\Request $request, Swoole\Http\Response $response) {
$response->end('<h1>Hello Swoole!</h1>');
});
$http->start();
} else {
$wait->wait();
System('ab -c 128 -n 100000 -k http://127.0.0.1:9501/ 2>&1');
Swoole\Process::kill($pid);
}
Swoole\Event::wait();
C
1
https://gitee.com/xzut/swoole.git
git@gitee.com:xzut/swoole.git
xzut
swoole
swoole-src
master

搜索帮助