Skip to content

Commit 863708a

Browse files
committed
Update bench.php
1 parent a060c7d commit 863708a

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

examples/bench.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
$bc->request_num = (int)$opt['n'];
2020
$bc->server_url = trim($opt['s']);
2121
$bc->server_config = parse_url($bc->server_url);
22-
$bc->send_data = str_repeat('a', 2032);
22+
$bc->send_data = "GET /hello.html HTTP/1.1\r\n";
23+
$bc->send_data .= "Host: 127.0.0.1\r\n";
24+
$bc->send_data .= "Connection: keep-alive\r\n";
25+
$bc->send_data .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\n";
26+
$bc->send_data .= "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36\r\n\r\n";
27+
2328
$bc->read_len = 2048;
2429
if(!empty($opt['p'])) $bc->show_detail = true;
2530

@@ -40,6 +45,7 @@ function long_tcp(Swoole_Benchmark $bc)
4045
{
4146
error:
4247
echo "Error: ".swoole_strerror($fp->errCode)."[{$fp->errCode}]\n";
48+
$fp = null;
4349
return false;
4450
}
4551
$start = $end;
@@ -55,6 +61,7 @@ function long_tcp(Swoole_Benchmark $bc)
5561
$start = $end;
5662
/*--------读取Sokcet-------*/
5763
$ret = $fp->recv();
64+
//var_dump($ret);
5865
$i++;
5966
if (empty($ret))
6067
{

examples/server/echo.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
$serv = new swoole_server("0.0.0.0", 9501);
33
$serv->set(array(
44
//'tcp_defer_accept' => 5,
5-
'worker_num' => 1,
6-
'daemonize' => true,
7-
'log_file' => '/tmp/swoole.log'
5+
//'worker_num' => 1,
6+
//'daemonize' => true,
7+
//'log_file' => '/tmp/swoole.log'
88
));
99
$serv->on('timer', function($serv, $interval) {
1010
echo "onTimer: $interval\n";
@@ -13,15 +13,15 @@
1313
//if($worker_id == 0) $serv->addtimer(1000);
1414
});
1515
$serv->on('connect', function ($serv, $fd, $from_id){
16-
echo "[#".posix_getpid()."]\tClient@[$fd:$from_id]: Connect.\n";
16+
//echo "[#".posix_getpid()."]\tClient@[$fd:$from_id]: Connect.\n";
1717
});
1818
$serv->on('receive', function (swoole_server $serv, $fd, $from_id, $data) {
19-
echo "[#".posix_getpid()."]\tClient[$fd]: $data\n";
19+
//echo "[#".posix_getpid()."]\tClient[$fd]: $data\n";
2020
$serv->send($fd, json_encode(array("hello" => '1213', "bat" => "ab")).PHP_EOL);
2121
//$serv->close($fd);
2222
});
2323
$serv->on('close', function ($serv, $fd, $from_id) {
24-
echo "[#".posix_getpid()."]\tClient@[$fd:$from_id]: Close.\n";
24+
//echo "[#".posix_getpid()."]\tClient@[$fd:$from_id]: Close.\n";
2525
});
2626
$serv->start();
2727

0 commit comments

Comments
 (0)