Metrics
0
Watch 281 Star 1.1K Fork 250

GVPswoole / swoole-srcCApache-2.0

Sign up for free
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
PHP的异步、并行、高性能网络通信引擎 spread retract

http://www.swoole.com/

  • C++ 38.3%
  • PHP 35.8%
  • C 24.8%
  • M4 0.5%
  • Shell 0.2%
  • Other 0.4%
Clone or download
benchmark.php 677 Bytes
Copy Edit Web IDE Raw Blame History
twosee authored 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);

Comment ( 0 )

You need to Sign in for post a comment

Help Search

Gitee_you_jiang_zheng_wen Zheng_wen_close