X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tests%2Fbenchmark.php;h=4c1fe120cbc5e1302ed32fd022f9616ef16a67ad;hb=442034639bc2504f4500890558c97ebc1ec80bbf;hp=43cbc42e58bcd76426c499eeaf9b256a513b3ed7;hpb=aeed2c3d2e362a5a14e69f1e65bd65a192d5eba7;p=plcapi.git diff --git a/tests/benchmark.php b/tests/benchmark.php index 43cbc42..4c1fe12 100644 --- a/tests/benchmark.php +++ b/tests/benchmark.php @@ -3,11 +3,13 @@ * Benchmarking suite for the PHP-XMLRPC lib. * * @author Gaetano Giunta - * @copyright (c) 2005-2015 G. Giunta + * @copyright (c) 2005-2020 G. Giunta * @license code licensed under the BSD License: see file license.txt * * @todo add a test for response ok in call testing * @todo add support for --help option to give users the list of supported parameters + * @todo make number of test iterations flexible + * @todo add https tests **/ use PhpXmlRpc\PhpXmlRpc; @@ -167,7 +169,7 @@ for ($i = 0; $i < $num_tests; $i++) { for ($k = 0; $k < $l; $k++) { $val1 = $value->arraymem($k); $out = array(); - while (list($name, $val) = $val1->structeach()) { + foreach($val1 as $name => $val) { $out[$name] = array(); $m = $val->arraysize(); for ($j = 0; $j < $m; $j++) { @@ -198,21 +200,23 @@ if (function_exists('xmlrpc_decode')) { if (!$xd) { + $num_tests = 25; + /// test multicall vs. many calls vs. keep-alives $encoder = new Encoder(); $value = $encoder->encode($data1, array('auto_dates')); $req = new Request('interopEchoTests.echoValue', array($value)); $reqs = array(); - for ($i = 0; $i < 25; $i++) { + for ($i = 0; $i < $num_tests; $i++) { $reqs[] = $req; } - $server = explode(':', $args['LOCALSERVER']); + $server = explode(':', $args['HTTPSERVER']); if (count($server) > 1) { - $srv = $server[1] . '://' . $server[0] . $args['URI']; - $c = new Client($args['URI'], $server[0], $server[1]); + $srv = $server[1] . '://' . $server[0] . $args['HTTPURI']; + $c = new Client($args['HTTPURI'], $server[0], $server[1]); } else { - $srv = $args['LOCALSERVER'] . $args['URI']; - $c = new Client($args['URI'], $args['LOCALSERVER']); + $srv = $args['HTTPSERVER'] . $args['HTTPURI']; + $c = new Client($args['HTTPURI'], $args['HTTPSERVER']); } // do not interfere with http compression $c->accepted_compression = array(); @@ -225,7 +229,7 @@ if (!$xd) { } begin_test($testName, 'http 10'); $response = array(); - for ($i = 0; $i < 25; $i++) { + for ($i = 0; $i < $num_tests; $i++) { $resp = $c->send($req); $response[] = $resp->value(); } @@ -234,7 +238,7 @@ if (!$xd) { if (function_exists('curl_init')) { begin_test($testName, 'http 11 w. keep-alive'); $response = array(); - for ($i = 0; $i < 25; $i++) { + for ($i = 0; $i < $num_tests; $i++) { $resp = $c->send($req, 10, 'http11'); $response[] = $resp->value(); } @@ -243,7 +247,7 @@ if (!$xd) { $c->keepalive = false; begin_test($testName, 'http 11'); $response = array(); - for ($i = 0; $i < 25; $i++) { + for ($i = 0; $i < $num_tests; $i++) { $resp = $c->send($req, 10, 'http11'); $response[] = $resp->value(); } @@ -263,7 +267,7 @@ if (!$xd) { begin_test($testName, 'http 10 w. compression'); $response = array(); - for ($i = 0; $i < 25; $i++) { + for ($i = 0; $i < $num_tests; $i++) { $resp = $c->send($req); $response[] = $resp->value(); } @@ -272,7 +276,7 @@ if (!$xd) { if (function_exists('curl_init')) { begin_test($testName, 'http 11 w. keep-alive and compression'); $response = array(); - for ($i = 0; $i < 25; $i++) { + for ($i = 0; $i < $num_tests; $i++) { $resp = $c->send($req, 10, 'http11'); $response[] = $resp->value(); } @@ -281,7 +285,7 @@ if (!$xd) { $c->keepalive = false; begin_test($testName, 'http 11 w. compression'); $response = array(); - for ($i = 0; $i < 25; $i++) { + for ($i = 0; $i < $num_tests; $i++) { $resp = $c->send($req, 10, 'http11'); $response[] = $resp->value(); }