Passed
Push — master ( d641b4...052fbc )
by Gaetano
05:20
created
extras/benchmark.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
 use PhpXmlRpc\Response;
20 20
 use PhpXmlRpc\Encoder;
21 21
 
22
-include_once __DIR__ . '/../vendor/autoload.php';
22
+include_once __DIR__.'/../vendor/autoload.php';
23 23
 
24
-include __DIR__ . '/tests/parse_args.php';
24
+include __DIR__.'/tests/parse_args.php';
25 25
 $args = argParser::getArgs();
26 26
 
27 27
 function begin_test($test_name, $test_case)
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     if (!isset($test_results[$test_name][$test_case])) {
42 42
         trigger_error('ending test that was not started');
43 43
     }
44
-    $test_results[$test_name][$test_case]['time'] = $end - $test_results[$test_name][$test_case]['time'];
44
+    $test_results[$test_name][$test_case]['time'] = $end-$test_results[$test_name][$test_case]['time'];
45 45
     $test_results[$test_name][$test_case]['result'] = $test_result;
46 46
     echo '.';
47 47
     flush();
@@ -75,24 +75,24 @@  discard block
 block discarded – undo
75 75
 }
76 76
 
77 77
 if ($is_web) {
78
-    echo "<h3>Using lib version: " . PhpXmlRpc::$xmlrpcVersion . " on PHP version: " . phpversion() . "</h3>\n";
78
+    echo "<h3>Using lib version: ".PhpXmlRpc::$xmlrpcVersion." on PHP version: ".phpversion()."</h3>\n";
79 79
     if ($xd) {
80
-        echo "<h4>XDEBUG profiling enabled: skipping remote tests. Trace file is: " . htmlspecialchars(xdebug_get_profiler_filename()) . "</h4>\n";
80
+        echo "<h4>XDEBUG profiling enabled: skipping remote tests. Trace file is: ".htmlspecialchars(xdebug_get_profiler_filename())."</h4>\n";
81 81
     }
82 82
     flush();
83 83
     ob_flush();
84 84
 } else {
85
-    echo "Using lib version: " . PhpXmlRpc::$xmlrpcVersion . " on PHP version: " . phpversion() . "\n";
85
+    echo "Using lib version: ".PhpXmlRpc::$xmlrpcVersion." on PHP version: ".phpversion()."\n";
86 86
     if ($xd) {
87
-        echo "XDEBUG profiling enabled: skipping remote tests\nTrace file is: " . xdebug_get_profiler_filename() . "\n";
87
+        echo "XDEBUG profiling enabled: skipping remote tests\nTrace file is: ".xdebug_get_profiler_filename()."\n";
88 88
     }
89 89
 }
90 90
 
91 91
 // test 'manual style' data encoding vs. 'automatic style' encoding
92 92
 begin_test('Data encoding (large array)', 'manual encoding');
93
-for ($i = 0; $i < $num_tests; $i++) {
93
+for ($i = 0; $i<$num_tests; $i++) {
94 94
     $vals = array();
95
-    for ($j = 0; $j < 10; $j++) {
95
+    for ($j = 0; $j<10; $j++) {
96 96
         $valarray = array();
97 97
         foreach ($data[$j] as $key => $val) {
98 98
             $values = array();
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
 begin_test('Data encoding (large array)', 'automatic encoding');
119 119
 $encoder = new Encoder();
120
-for ($i = 0; $i < $num_tests; $i++) {
120
+for ($i = 0; $i<$num_tests; $i++) {
121 121
     $value = $encoder->encode($data, array('auto_dates'));
122 122
     $out = $value->serialize();
123 123
 }
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 
126 126
 if (function_exists('xmlrpc_set_type')) {
127 127
     begin_test('Data encoding (large array)', 'xmlrpc-epi encoding');
128
-    for ($i = 0; $i < $num_tests; $i++) {
129
-        for ($j = 0; $j < 10; $j++) {
128
+    for ($i = 0; $i<$num_tests; $i++) {
129
+        for ($j = 0; $j<10; $j++) {
130 130
             foreach ($keys as $k) {
131 131
                 xmlrpc_set_type($data[$j][$k][4], 'datetime');
132 132
                 xmlrpc_set_type($data[$j][$k][8], 'datetime');
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
 // test 'old style' data decoding vs. 'automatic style' decoding
141 141
 $dummy = new Request('');
142 142
 $out = new Response($value);
143
-$in = '<?xml version="1.0" ?>' . "\n" . $out->serialize();
143
+$in = '<?xml version="1.0" ?>'."\n".$out->serialize();
144 144
 
145 145
 begin_test('Data decoding (large array)', 'manual decoding');
146
-for ($i = 0; $i < $num_tests; $i++) {
146
+for ($i = 0; $i<$num_tests; $i++) {
147 147
     $response = $dummy->ParseResponse($in, true);
148 148
     $value = $response->value();
149 149
     $result = array();
150
-    foreach($value as $val1) {
150
+    foreach ($value as $val1) {
151 151
         $out = array();
152
-        foreach($val1 as $name => $val) {
152
+        foreach ($val1 as $name => $val) {
153 153
             $out[$name] = array();
154
-            foreach($val as $data) {
154
+            foreach ($val as $data) {
155 155
                 $out[$name][] = $data->scalarval();
156 156
             }
157 157
         }
@@ -161,18 +161,18 @@  discard block
 block discarded – undo
161 161
 end_test('Data decoding (large array)', 'manual decoding', $result);
162 162
 
163 163
 begin_test('Data decoding (large array)', 'manual decoding deprecated');
164
-for ($i = 0; $i < $num_tests; $i++) {
164
+for ($i = 0; $i<$num_tests; $i++) {
165 165
     $response = $dummy->ParseResponse($in, true);
166 166
     $value = $response->value();
167 167
     $result = array();
168 168
     $l = $value->arraysize();
169
-    for ($k = 0; $k < $l; $k++) {
169
+    for ($k = 0; $k<$l; $k++) {
170 170
         $val1 = $value->arraymem($k);
171 171
         $out = array();
172
-        foreach($val1 as $name => $val) {
172
+        foreach ($val1 as $name => $val) {
173 173
             $out[$name] = array();
174 174
             $m = $val->arraysize();
175
-            for ($j = 0; $j < $m; $j++) {
175
+            for ($j = 0; $j<$m; $j++) {
176 176
                 $data = $val->arraymem($j);
177 177
                 $out[$name][] = $data->scalarval();
178 178
             }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 end_test('Data decoding (large array)', 'manual decoding deprecated', $result);
184 184
 
185 185
 begin_test('Data decoding (large array)', 'automatic decoding');
186
-for ($i = 0; $i < $num_tests; $i++) {
186
+for ($i = 0; $i<$num_tests; $i++) {
187 187
     $response = $dummy->ParseResponse($in, true, 'phpvals');
188 188
     $value = $response->value();
189 189
 }
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
 if (function_exists('xmlrpc_decode')) {
193 193
     begin_test('Data decoding (large array)', 'xmlrpc-epi decoding');
194
-    for ($i = 0; $i < $num_tests; $i++) {
194
+    for ($i = 0; $i<$num_tests; $i++) {
195 195
         $response = $dummy->ParseResponse($in, true, 'xml');
196 196
         $value = xmlrpc_decode($response->value());
197 197
     }
@@ -207,15 +207,15 @@  discard block
 block discarded – undo
207 207
     $value = $encoder->encode($data1, array('auto_dates'));
208 208
     $req = new Request('interopEchoTests.echoValue', array($value));
209 209
     $reqs = array();
210
-    for ($i = 0; $i < $num_tests; $i++) {
210
+    for ($i = 0; $i<$num_tests; $i++) {
211 211
         $reqs[] = $req;
212 212
     }
213 213
     $server = explode(':', $args['HTTPSERVER']);
214
-    if (count($server) > 1) {
215
-        $srv = $server[1] . '://' . $server[0] . $args['HTTPURI'];
214
+    if (count($server)>1) {
215
+        $srv = $server[1].'://'.$server[0].$args['HTTPURI'];
216 216
         $c = new Client($args['HTTPURI'], $server[0], $server[1]);
217 217
     } else {
218
-        $srv = $args['HTTPSERVER'] . $args['HTTPURI'];
218
+        $srv = $args['HTTPSERVER'].$args['HTTPURI'];
219 219
         $c = new Client($args['HTTPURI'], $args['HTTPSERVER']);
220 220
     }
221 221
     // do not interfere with http compression
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     }
230 230
     begin_test($testName, 'http 10');
231 231
     $response = array();
232
-    for ($i = 0; $i < $num_tests; $i++) {
232
+    for ($i = 0; $i<$num_tests; $i++) {
233 233
         $resp = $c->send($req);
234 234
         $response[] = $resp->value();
235 235
     }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     if (function_exists('curl_init')) {
239 239
         begin_test($testName, 'http 11 w. keep-alive');
240 240
         $response = array();
241
-        for ($i = 0; $i < $num_tests; $i++) {
241
+        for ($i = 0; $i<$num_tests; $i++) {
242 242
             $resp = $c->send($req, 10, 'http11');
243 243
             $response[] = $resp->value();
244 244
         }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
         $c->keepalive = false;
248 248
         begin_test($testName, 'http 11');
249 249
         $response = array();
250
-        for ($i = 0; $i < $num_tests; $i++) {
250
+        for ($i = 0; $i<$num_tests; $i++) {
251 251
             $resp = $c->send($req, 10, 'http11');
252 252
             $response[] = $resp->value();
253 253
         }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 
268 268
         begin_test($testName, 'http 10 w. compression');
269 269
         $response = array();
270
-        for ($i = 0; $i < $num_tests; $i++) {
270
+        for ($i = 0; $i<$num_tests; $i++) {
271 271
             $resp = $c->send($req);
272 272
             $response[] = $resp->value();
273 273
         }
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         if (function_exists('curl_init')) {
277 277
             begin_test($testName, 'http 11 w. keep-alive and compression');
278 278
             $response = array();
279
-            for ($i = 0; $i < $num_tests; $i++) {
279
+            for ($i = 0; $i<$num_tests; $i++) {
280 280
                 $resp = $c->send($req, 10, 'http11');
281 281
                 $response[] = $resp->value();
282 282
             }
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
             $c->keepalive = false;
286 286
             begin_test($testName, 'http 11 w. compression');
287 287
             $response = array();
288
-            for ($i = 0; $i < $num_tests; $i++) {
288
+            for ($i = 0; $i<$num_tests; $i++) {
289 289
                 $resp = $c->send($req, 10, 'http11');
290 290
                 $response[] = $resp->value();
291 291
             }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 foreach ($test_results as $test => $results) {
307 307
     echo "\nTEST: $test\n";
308 308
     foreach ($results as $case => $data) {
309
-        echo "  $case: {$data['time']} secs - Output data CRC: " . crc32(serialize($data['result'])) . "\n";
309
+        echo "  $case: {$data['time']} secs - Output data CRC: ".crc32(serialize($data['result']))."\n";
310 310
     }
311 311
 }
312 312
 
Please login to merge, or discard this patch.