* Benchmarking suite for the PHP-XMLRPC lib.
*
* @author Gaetano Giunta
- * @copyright (c) 2005-2015 G. Giunta
+ * @copyright (c) 2005-2021 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 a check 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;
use PhpXmlRpc\Response;
use PhpXmlRpc\Encoder;
+/// @todo allow autoloading when the library is installed as dependency
include_once __DIR__ . '/../vendor/autoload.php';
-include __DIR__ . '/parse_args.php';
+include __DIR__ . '/../tests/parse_args.php';
$args = argParser::getArgs();
function begin_test($test_name, $test_case)
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++) {
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();
}
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();
}
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();
}
$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();
}
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();
}
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();
}
$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();
}