<?php
require 'libserverbench.phar';
$server = new \ServerBench\App\Server\Server('tcp://127.0.0.1:12345', function ($msg) {
return $msg;
});
$daemon = false;
$server->run($daemon);
#cli utils
#start
php serverbench.phar --pidfile=./pid --dir=./ --app=app.php -c app.ini --daemon
#stop
php serverbench.phar --stop --pidfile=./pid
#reload
php serverbench.phar --reload --pidfile=./pid
#status
php serverbench.phar --status --pidfile=./pid
<?php
// app entrance
class App
{
public function init()
{
// connect database or anything else to ready
}
public function fini()
{
// do something to clean up
}
public function process($msg)
{
// process msg from client
// here is an echo server
return $msg;
}
}
return new App();
# php benchmark.php -C {address to connect} -c {clients/concurrency} -T {time to testing} -L {msg's length}
php benchmark.php -C tcp://127.0.0.1:12345 -c 300 -T 15 -L 100