|
9 | 9 | # Company : Code24 BV, The Netherlands #
|
10 | 10 | # Author : Sergey Dryabzhinsky #
|
11 | 11 | # Company : Rusoft Ltd, Russia #
|
12 |
| -# Date : Aug 08, 2018 # |
13 |
| -# Version : 1.0.32 # |
| 12 | +# Date : MAy 01, 2019 # |
| 13 | +# Version : 1.0.33 # |
14 | 14 | # License : Creative Commons CC-BY license #
|
15 | 15 | # Website : https://github.com/rusoft/php-simple-benchmark-script #
|
16 | 16 | # Website : https://git.rusoft.ru/open-source/php-simple-benchmark-script #
|
17 | 17 | # #
|
18 | 18 | ################################################################################
|
19 | 19 | */
|
20 | 20 |
|
21 |
| -$scriptVersion = '1.0.32'; |
| 21 | +$scriptVersion = '1.0.33'; |
| 22 | + |
| 23 | +ini_set('display_errors', 0); |
| 24 | +ini_set('error_log', null); |
| 25 | +error_reporting(E_ERROR | E_WARNING | E_PARSE); |
| 26 | +// Disable explicit error reporting |
| 27 | +$xdebug = ini_get('xdebug.default_enable'); |
| 28 | +ini_set('xdebug.show_exception_trace', 0); |
| 29 | + |
| 30 | +if ($xdebug) { |
| 31 | + print('<pre><<< ERROR >>> You need to disable Xdebug extension! It greatly slow things down!</pre>'.PHP_EOL); |
| 32 | + exit(1); |
| 33 | +} |
22 | 34 |
|
23 | 35 | // Used in hacks/fixes checks
|
24 | 36 | $phpversion = explode('.', PHP_VERSION);
|
25 | 37 |
|
26 | 38 | $dropDead = false;
|
| 39 | +// No php < 4 |
27 | 40 | if ((int)$phpversion[0] < 4) {
|
28 | 41 | $dropDead = true;
|
29 | 42 | }
|
| 43 | +// No php <= 4.3 |
30 | 44 | if ((int)$phpversion[0] == 4 && (int)$phpversion[1] < 3) {
|
31 | 45 | $dropDead = true;
|
32 | 46 | }
|
33 | 47 | if ($dropDead) {
|
34 |
| - print('<pre><<< ERROR >>> Need PHP 4.3+! Current version is ' . PHP_VERSION . '</pre>'); |
| 48 | + print('<pre><<< ERROR >>> Need PHP 4.3+! Current version is ' . PHP_VERSION . '</pre>'.PHP_EOL); |
35 | 49 | exit(1);
|
36 | 50 | }
|
37 | 51 | if (!defined('PHP_MAJOR_VERSION')) {
|
|
41 | 55 | define('PHP_MINOR_VERSION', (int)$phpversion[1]);
|
42 | 56 | }
|
43 | 57 |
|
44 |
| -$stringTest = " the quick <b>brown</b> fox jumps <i>over</i> the lazy dog and eat <span>lorem ipsum</span><br/> Valar morghulis <br/>\n\rабыр\nвалар дохаэрис "; |
| 58 | +$stringTest = " the quick <b>brown</b> fox jumps <i>over</i> the lazy dog and eat <span>lorem ipsum</span><br/> Valar morghulis <br/>\n\rабыр\nвалар дохаэрис <span class='alert alert-danger'>У нас закончились ложки, Нео!</span> "; |
45 | 59 | $regexPattern = '/[\s,]+/';
|
46 | 60 |
|
47 | 61 | /** ------------------------------- Main Defaults ------------------------------- */
|
|
53 | 67 |
|
54 | 68 | $recalculateLimits = 1;
|
55 | 69 |
|
| 70 | +$printDumbTest = 0; |
| 71 | + |
56 | 72 | $outputTestsList = 0;
|
57 | 73 |
|
58 | 74 | $showOnlySystemInfo = 0;
|
|
80 | 96 | $recalculateLimits = 0;
|
81 | 97 | }
|
82 | 98 |
|
| 99 | +if ((int)getenv('PRINT_DUMB_TEST')) { |
| 100 | + $printDumbTest = 1; |
| 101 | +} |
| 102 | +if (isset($_GET['print_dumb_test']) && (int)$_GET['print_dumb_test']) { |
| 103 | + $printDumbTest = 1; |
| 104 | +} |
| 105 | + |
83 | 106 | if ((int)getenv('LIST_TESTS')) {
|
84 | 107 | $outputTestsList = 1;
|
85 | 108 | }
|
|
104 | 127 | // http://php.net/manual/ru/function.getopt.php example #2
|
105 | 128 | $shortopts = "h";
|
106 | 129 | $shortopts .= "d";
|
| 130 | +$shortopts .= "D"; |
107 | 131 | $shortopts .= "L";
|
108 | 132 | $shortopts .= "I";
|
109 | 133 | $shortopts .= "m:"; // Обязательное значение
|
|
113 | 137 | $longopts = array(
|
114 | 138 | "help",
|
115 | 139 | "dont-recalc",
|
| 140 | + "dumb-test-print", |
116 | 141 | "list-tests",
|
117 | 142 | "system-info",
|
118 | 143 | "memory-limit:", // Обязательное значение
|
|
147 | 172 | . PHP_EOL
|
148 | 173 | . ' -h|--help - print this help and exit' . PHP_EOL
|
149 | 174 | . ' -d|--dont-recalc - do not recalculate test times / operations count even if memory of execution time limits are low' . PHP_EOL
|
| 175 | + . ' -D|--dumb-test-print - print dumb test time, for debug purpose' . PHP_EOL |
150 | 176 | . ' -L|--list-tests - output list of available tests and exit' . PHP_EOL
|
151 |
| - . ' -I|--system-info - output system info but do not run tests and exit' . PHP_EOL |
| 177 | + . ' -I|--system-info - output system info but do not run tests and exit' . PHP_EOL |
152 | 178 | . ' -m|--memory-limit <Mb> - set memory_limit value in Mb, defaults to 256 (Mb)' . PHP_EOL
|
153 | 179 | . ' -t|--time-limit <sec> - set max_execution_time value in seconds, defaults to 600 (sec)' . PHP_EOL
|
154 | 180 | . ' -T|--run-test <name> - run selected test, test names from --list-tests output, can be defined multiple times' . PHP_EOL
|
|
165 | 191 | . PHP_EOL
|
166 | 192 | . ' -h - print this help and exit' . PHP_EOL
|
167 | 193 | . ' -d - do not recalculate test times / operations count even if memory of execution time limits are low' . PHP_EOL
|
| 194 | + . ' -D - print dumb test time, for debug purpose' . PHP_EOL |
168 | 195 | . ' -L - output list of available tests and exit' . PHP_EOL
|
169 | 196 | . ' -I - output system info but do not run tests and exit' . PHP_EOL
|
170 | 197 | . ' -m <Mb> - set memory_limit value in Mb, defaults to 256 (Mb)' . PHP_EOL
|
|
192 | 219 | $recalculateLimits = 0;
|
193 | 220 | break;
|
194 | 221 |
|
| 222 | + case 'D': |
| 223 | + case 'dumb-test-print': |
| 224 | + $printDumbTest = 1; |
| 225 | + break; |
| 226 | + |
195 | 227 | case 'L':
|
196 | 228 | case 'list-tests':
|
197 | 229 | $outputTestsList = 1;
|
|
265 | 297 | /** ---------------------------------- Tests limits - to recalculate -------------------------------------------- */
|
266 | 298 |
|
267 | 299 | // Gathered on this machine
|
268 |
| -$loopMaxPhpTimesMHz = 3700; |
| 300 | +$loopMaxPhpTimesMHz = 3000; |
269 | 301 | // How much time needed for tests on this machine
|
270 | 302 | $loopMaxPhpTimes = array(
|
271 |
| - '4.4' => 235, |
272 |
| - '5.2' => 150, |
273 |
| - '5.3' => 130, |
| 303 | + '4.4' => 350, |
| 304 | + '5.2' => 237, |
| 305 | + '5.3' => 211, |
274 | 306 | // 5.4, 5.5, 5.6
|
275 |
| - '5' => 130, |
| 307 | + '5.4' => 191, |
| 308 | + '5.5' => 189, |
| 309 | + '5.6' => 190, |
276 | 310 | // 7.0, 7.1
|
277 |
| - '7' => 65, |
| 311 | + '7.0' => 109, |
| 312 | + '7.1' => 107, |
| 313 | + '7.2' => 105, |
| 314 | + '7.3' => 92, |
278 | 315 | );
|
279 | 316 | $dumbTestMaxPhpTimes = array(
|
280 |
| - '4.4' => 1.3, |
281 |
| - '5.2' => 0.97, |
282 |
| - '5.3' => 0.95, |
| 317 | + '4.4' => 2.13, |
| 318 | + '5.2' => 1.82, |
| 319 | + '5.3' => 1.82, |
283 | 320 | // 5.4, 5.5, 5.6
|
284 |
| - '5' => 0.95, |
| 321 | + '5.4' => 1.71, |
| 322 | + '5.5' => 1.86, |
| 323 | + '5.6' => 1.92, |
285 | 324 | // 7.0, 7.1
|
286 |
| - '7' => 0.58, |
| 325 | + '7.0' => 1.19, |
| 326 | + '7.1' => 1.19, |
| 327 | + '7.2' => 1.18, |
| 328 | + '7.3' => 1.05, |
287 | 329 | );
|
288 | 330 | $testsLoopLimits = array(
|
289 |
| - '01_math' => 1400000, |
| 331 | + '01_math' => 1000000, |
290 | 332 | // Nice dice roll
|
291 | 333 | // That limit gives around 256Mb too
|
292 | 334 | '02_string_concat' => 7700000,
|
|
304 | 346 | '12_unserialize' => 1300000,
|
305 | 347 | '13_array_loop' => 200,
|
306 | 348 | '14_array_loop' => 200,
|
307 |
| - '15_loops' => 190000000, |
308 |
| - '16_loop_ifelse' => 90000000, |
309 |
| - '17_loop_ternary' => 90000000, |
| 349 | + '15_loops' => 100000000, |
| 350 | + '16_loop_ifelse' => 50000000, |
| 351 | + '17_loop_ternary' => 50000000, |
310 | 352 | '18_1_loop_def' => 20000000,
|
311 | 353 | '18_2_loop_undef' => 20000000,
|
312 |
| - '19_type_func' => 5000000, |
313 |
| - '20_type_conv' => 5000000, |
| 354 | + '19_type_func' => 3000000, |
| 355 | + '20_type_conv' => 3000000, |
314 | 356 | '21_loop_except' => 4000000,
|
315 | 357 | '22_loop_nullop' => 50000000,
|
316 | 358 | '23_loop_spaceship' => 50000000,
|
317 | 359 | '24_xmlrpc_encode' => 200000,
|
318 | 360 | '25_xmlrpc_decode' => 30000,
|
| 361 | + '26_1_public' => 5000000, |
| 362 | + '26_2_getset' => 5000000, |
| 363 | + '26_3_magic' => 5000000, |
319 | 364 | );
|
320 | 365 | $totalOps = 0;
|
321 | 366 |
|
322 | 367 | /** ---------------------------------- Common functions -------------------------------------------- */
|
323 | 368 |
|
| 369 | +/** |
| 370 | + * Gt pretty OS release name, if available |
| 371 | + */ |
| 372 | +function get_current_os() |
| 373 | +{ |
| 374 | + $osFile = '/etc/os-release'; |
| 375 | + $result = PHP_OS; |
| 376 | + if (file_exists($osFile)) { |
| 377 | + $f = fopen($osFile, 'r'); |
| 378 | + while (!feof($f)) { |
| 379 | + $line = trim(fgets($f, 1000000)); |
| 380 | + if (strpos($line, 'PRETTY_NAME=') === 0) { |
| 381 | + $s = explode('=', $line); |
| 382 | + $result = array_pop($s); |
| 383 | + $result = str_replace('"','', $result); |
| 384 | + } |
| 385 | + } |
| 386 | + } |
| 387 | + return $result; |
| 388 | +} |
| 389 | + |
324 | 390 | function get_microtime()
|
325 | 391 | {
|
326 | 392 | $time = microtime(true);
|
@@ -658,7 +724,9 @@ function mymemory_usage()
|
658 | 724 | // TIME WASTED HERE
|
659 | 725 | $dumbTestTime = dumb_test_Functions();
|
660 | 726 | // Debug
|
661 |
| -// print($dumbTestTime); |
| 727 | + if ($printDumbTest) { |
| 728 | + print("Dumb test time: " .$dumbTestTime . PHP_EOL); |
| 729 | + } |
662 | 730 | if ($dumbTestTime > $dumbTestTimeMax) {
|
663 | 731 | $factor *= 1.0 * $dumbTestTimeMax / $dumbTestTime;
|
664 | 732 | }
|
@@ -1394,6 +1462,7 @@ function test_25_XmlRpc_Decode()
|
1394 | 1462 | . str_pad("Start", $padInfo) . " : " . date("Y-m-d H:i:s") . "\n"
|
1395 | 1463 | . str_pad("Server", $padInfo) . " : " . php_uname('s') . '/' . php_uname('r') . ' ' . php_uname('m') . "\n"
|
1396 | 1464 | . str_pad("Platform", $padInfo) . " : " . PHP_OS . "\n"
|
| 1465 | + . str_pad("System", $padInfo) . " : " . get_current_os() . "\n" |
1397 | 1466 | . str_pad("CPU", $padInfo) . " :\n"
|
1398 | 1467 | . str_pad("model", $padInfo, ' ', STR_PAD_LEFT) . " : " . $cpuInfo['model'] . "\n"
|
1399 | 1468 | . str_pad("cores", $padInfo, ' ', STR_PAD_LEFT) . " : " . $cpuInfo['cores'] . "\n"
|
|
0 commit comments