WIP tests on Docker
[plcapi.git] / tests / benchmark.php
index 32a3fed..8ef4587 100644 (file)
@@ -3,8 +3,8 @@
  * Benchmarking suite for the PHP-XMLRPC lib.
  *
  * @author Gaetano Giunta
- * @copyright (c) 2005-2015 G. Giunta
- * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt
+ * @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
@@ -86,7 +86,7 @@ if ($is_web) {
     }
 }
 
-// test 'old style' data encoding vs. 'automatic style' encoding
+// test 'manual style' data encoding vs. 'automatic style' encoding
 begin_test('Data encoding (large array)', 'manual encoding');
 for ($i = 0; $i < $num_tests; $i++) {
     $vals = array();
@@ -145,12 +145,32 @@ for ($i = 0; $i < $num_tests; $i++) {
     $response = $dummy->ParseResponse($in, true);
     $value = $response->value();
     $result = array();
-    for ($k = 0; $k < $value->arraysize(); $k++) {
+    foreach($value as $val1) {
+        $out = array();
+        foreach($val1 as $name => $val) {
+            $out[$name] = array();
+            foreach($val as $data) {
+                $out[$name][] = $data->scalarval();
+            }
+        }
+        $result[] = $out;
+    }
+}
+end_test('Data decoding (large array)', 'manual decoding', $result);
+
+begin_test('Data decoding (large array)', 'manual decoding deprecated');
+for ($i = 0; $i < $num_tests; $i++) {
+    $response = $dummy->ParseResponse($in, true);
+    $value = $response->value();
+    $result = array();
+    $l = $value->arraysize();
+    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();
-            for ($j = 0; $j < $val->arraysize(); $j++) {
+            $m = $val->arraysize();
+            for ($j = 0; $j < $m; $j++) {
                 $data = $val->arraymem($j);
                 $out[$name][] = $data->scalarval();
             }
@@ -158,7 +178,7 @@ for ($i = 0; $i < $num_tests; $i++) {
         $result[] = $out;
     }
 }
-end_test('Data decoding (large array)', 'manual decoding', $result);
+end_test('Data decoding (large array)', 'manual decoding deprecated', $result);
 
 begin_test('Data decoding (large array)', 'automatic decoding');
 for ($i = 0; $i < $num_tests; $i++) {
@@ -186,13 +206,13 @@ if (!$xd) {
     for ($i = 0; $i < 25; $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();