readme
[plcapi.git] / tests / benchmark.php
index 7150d90..4c1fe12 100644 (file)
@@ -3,11 +3,13 @@
  * Benchmarking suite for the PHP-XMLRPC lib.
  *
  * @author Gaetano Giunta
- * @copyright (c) 2005-2019 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;
@@ -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();
             }