9
9
# Company : Code24 BV, The Netherlands #
10
10
# Author : Sergey Dryabzhinsky #
11
11
# Company : Rusoft Ltd, Russia #
12
- # Date : Jun 7 , 2025 #
13
- # Version : 1.0.66 #
12
+ # Date : Jun 13 , 2025 #
13
+ # Version : 1.0.67-dev #
14
14
# License : Creative Commons CC-BY license #
15
15
# Website : https://github.com/rusoft/php-simple-benchmark-script #
16
16
# Website : https://gitea.rusoft.ru/open-source/php-simple-benchmark-script #
20
20
21
21
include_once ("php-options.php " );
22
22
23
- $ scriptVersion = '1.0.66 ' ;
23
+ $ scriptVersion = '1.0.67-dev ' ;
24
24
25
25
// Special string to flush buffers, nginx for example
26
26
$ flushStr = '<!-- ' .str_repeat (" " , 8192 ).' --> ' ;
197
197
198
198
$ printJson = 0 ;
199
199
200
+ $ printRaw = 0 ;
201
+
200
202
$ printMachine = 0 ;
201
203
202
204
$ recalculateLimits = 1 ;
237
239
if ($ x = (int )getenv ('PRINT_JSON ' )) {
238
240
$ printJson = $ x ;
239
241
}
242
+ if ($ x = (int )getenv ('PRINT_RAW ' )) {
243
+ $ printRaw = $ x ;
244
+ }
240
245
if (isset ($ _GET ['print_json ' ]) && $ x = (int )$ _GET ['print_json ' ]) {
241
246
$ printJson = $ x ;
242
247
}
248
+ if (isset ($ _GET ['print_raw ' ]) && $ x = (int )$ _GET ['print_raw ' ]) {
249
+ $ printRaw = $ x ;
250
+ }
243
251
if ($ printJson ) $ printMachine = 0 ;
244
252
245
253
if ($ x = (int )getenv ('PRINT_MACHINE ' )) {
@@ -368,6 +376,7 @@ function gethostname() {
368
376
$ shortopts .= "d " ;
369
377
$ shortopts .= "C " ;
370
378
$ shortopts .= "J " ;
379
+ $ shortopts .= "R " ;
371
380
$ shortopts .= "M " ;
372
381
$ shortopts .= "D " ;
373
382
$ shortopts .= "L " ;
@@ -382,6 +391,7 @@ function gethostname() {
382
391
"debug " ,
383
392
"dont-use-colors " ,
384
393
"print-json " ,
394
+ "print-raw " ,
385
395
"print-machine " ,
386
396
"dont-recalc " ,
387
397
"dumb-test-print " ,
@@ -430,6 +440,11 @@ function gethostname() {
430
440
$ printMachine = 0 ;
431
441
break ;
432
442
443
+ case 'R ' :
444
+ case 'print-raw ' :
445
+ $ printRaw = 1 ;
446
+ break ;
447
+
433
448
case 'M ' :
434
449
case 'print-machine ' :
435
450
$ printMachine = 1 ;
@@ -480,12 +495,13 @@ function gethostname() {
480
495
PHP_EOL
481
496
. 'PHP Benchmark Performance Script, version ' . $ scriptVersion . PHP_EOL
482
497
. PHP_EOL
483
- . 'Usage: ' . basename (__FILE__ ) . ' [-h|--help] [-x|--debug] [-C|--dont-use-colors] [-J|--print-json] [-M|--print-machine] [-d|--dont-recalc] [-D|--dumb-test-print] [-L|--list-tests] [-I|--system-info] [-S|--do-not-task-set] [-m|--memory-limit=130] [-t|--time-limit=600] [-T|--run-test=name] [-S|--skip-test=pattern] ' . PHP_EOL
498
+ . 'Usage: ' . basename (__FILE__ ) . ' [-h|--help] [-x|--debug] [-C|--dont-use-colors] [-J|--print-json] [-R|--print-raw] [- M|--print-machine] [-d|--dont-recalc] [-D|--dumb-test-print] [-L|--list-tests] [-I|--system-info] [-S|--do-not-task-set] [-m|--memory-limit=130] [-t|--time-limit=600] [-T|--run-test=name] [-S|--skip-test=pattern] ' . PHP_EOL
484
499
. PHP_EOL
485
500
. ' -h|--help - print this help and exit ' . PHP_EOL
486
501
. ' -x|--debug - enable debug mode, raise output level ' . PHP_EOL
487
- . ' -C|--dont-use-colors - disable printing html-span or color sequences for capable terminal: xterm, *-color, *-256color. And not use it in JSON/machine mode. ' . PHP_EOL
502
+ . ' -C|--dont-use-colors - disable printing html-span or color sequences for capable terminal: xterm, *-color, *-256color. And not using it in JSON/machine mode. ' . PHP_EOL
488
503
. ' -J|--print-json - enable printing only in JSON format, useful for automated tests. disables print-machine. ' . PHP_EOL
504
+ . ' -R|--print-raw - enable printing only raw values, no human readable forms, useful for automated tests. ' . PHP_EOL
489
505
. ' -M|--print-machine - enable printing only in machine parsable format, useful for automated tests. disables print-json. ' . PHP_EOL
490
506
. ' -d|--dont-recalc - do not recalculate test times / operations count even if memory of execution time limits are low ' . PHP_EOL
491
507
. ' -D|--dumb-test-print - print dumb test time, for debug purpose ' . PHP_EOL
@@ -504,12 +520,13 @@ function gethostname() {
504
520
PHP_EOL
505
521
. 'PHP Benchmark Performance Script, version ' . $ scriptVersion . PHP_EOL
506
522
. PHP_EOL
507
- . 'Usage: ' . basename (__FILE__ ) . ' [-h] [-x] [-C] [-J] [-M] [-d] [-D] [-L] [-I] [-S] [-m 130] [-t 600] [-T name] ' . PHP_EOL
523
+ . 'Usage: ' . basename (__FILE__ ) . ' [-h] [-x] [-C] [-J] [-R] [- M] [-d] [-D] [-L] [-I] [-S] [-m 130] [-t 600] [-T name] ' . PHP_EOL
508
524
. PHP_EOL
509
525
. ' -h - print this help and exit ' . PHP_EOL
510
526
. ' -x - enable debug mode, raise output level ' . PHP_EOL
511
- . ' -C - disable printing html-span or color sequences for capable terminal: xterm, *-color, *-256color. And not use it in JSON/machine mode. ' . PHP_EOL
527
+ . ' -C - disable printing html-span or color sequences for capable terminal: xterm, *-color, *-256color. And not using it in JSON/machine mode. ' . PHP_EOL
512
528
. ' -J - enable printing only in JSON format, useful for automated tests. disables print-machine. ' . PHP_EOL
529
+ . ' -R - enable printing only raw values, no human readable forms, useful for automated tests. ' . PHP_EOL
513
530
. ' -M - enable printing only in machine parsable format, useful for automated tests. disables print-json. ' . PHP_EOL
514
531
. ' -d - do not recalculate test times / operations count even if memory of execution time limits are low ' . PHP_EOL
515
532
. ' -D - print dumb test time, for debug purpose ' . PHP_EOL
@@ -579,6 +596,8 @@ function gethostname() {
579
596
case 'dont-use-colors ' :
580
597
case 'J ' :
581
598
case 'print-json ' :
599
+ case 'R ' :
600
+ case 'print-raw ' :
582
601
case 'M ' :
583
602
case 'print-machine ' :
584
603
case 'D ' :
@@ -1562,8 +1581,13 @@ function mymemory_usage()
1562
1581
*/
1563
1582
function format_result_test ($ diffSeconds , $ opCount , $ memory = 0 )
1564
1583
{
1565
- global $ cpuInfo , $ rawValues4json ;
1584
+ global $ cpuInfo , $ rawValues4json, $ printRaw ;
1566
1585
if ($ diffSeconds ) {
1586
+ if ($ printRaw ) {
1587
+ return array ($ diffSeconds , number_format ($ diffSeconds , 3 , '. ' , '' ),
1588
+ $ opCount , 0 , $ memory
1589
+ );
1590
+ }
1567
1591
$ ops = $ opCount / $ diffSeconds ;
1568
1592
$ ops_v = convert_si ($ ops );
1569
1593
$ ops_u = prefix_si ($ ops );
@@ -1589,6 +1613,9 @@ function format_result_test($diffSeconds, $opCount, $memory = 0)
1589
1613
if ($ rawValues4json ) {
1590
1614
return array (0 , 0 , 0 , 0 , 0 );
1591
1615
}
1616
+ if ($ printRaw ) {
1617
+ return array (0 , 0 , 0 , 0 , 0 );
1618
+ }
1592
1619
return array (0 , '0.000 ' , 'x.xx ' , 'x.xx ' , 0 );
1593
1620
}
1594
1621
}
@@ -1947,12 +1974,14 @@ function filter_out_name_by_pattern($key)
1947
1974
if (!defined ('SODIUM_LIBRARY_VERSION ' )) define ('SODIUM_LIBRARY_VERSION ' , '-.-.- ' );
1948
1975
if (!defined ('INTL_ICU_VERSION ' )) define ('INTL_ICU_VERSION ' , '-.- ' );
1949
1976
if (!defined ('LIBZSTD_VERSION_STRING ' )) define ('LIBZSTD_VERSION_STRING ' , '-.-.- ' );
1977
+ if (!defined ('BROTLI_VERSION_TEXT ' )) define ('BROTLI_VERSION_TEXT ' , '-.-.- ' );
1950
1978
1951
1979
function print_results_common ()
1952
1980
{
1953
1981
$ total = 0 ;
1954
1982
1955
1983
global $ availableFunctions ;
1984
+ global $ printRaw ;
1956
1985
global $ line , $ padHeader , $ cpuInfo , $ padInfo , $ scriptVersion , $ maxTime , $ originTimeLimit , $ originMemoryLimit , $ cryptAlgoName , $ memoryLimitMb ;
1957
1986
global $ flushStr , $ has_apc , $ has_pcre , $ has_intl , $ has_json , $ has_simplexml , $ has_dom , $ has_mbstring , $ has_opcache , $ has_xcache ;
1958
1987
global $ has_gd , $ has_gdgif , $ has_gdpng , $ has_gdjpg , $ has_gdwebp , $ has_gdavif ;
@@ -2039,7 +2068,12 @@ function print_results_common()
2039
2068
2040
2069
if (!$ showOnlySystemInfo ) {
2041
2070
2042
- echo str_pad ('TEST NAME ' , $ padLabel ) . " : "
2071
+ if ($ printRaw )
2072
+ echo str_pad ('TEST NAME ' , $ padLabel ) . " : "
2073
+ . str_pad ('SECONDS ' , 9 + 4 , ' ' , STR_PAD_LEFT ) . " | " . str_pad ('OPS ' , 9 + 4 , ' ' , STR_PAD_LEFT ) . " | " . str_pad ('OP/SEC/MHz ' , 9 + 7 , ' ' , STR_PAD_LEFT ) . " | " . str_pad ('MEMORY b ' , 10 , ' ' , STR_PAD_LEFT ) . "\n"
2074
+ . "$ line \n" . $ flushStr ;
2075
+ else
2076
+ echo str_pad ('TEST NAME ' , $ padLabel ) . " : "
2043
2077
. str_pad ('SECONDS ' , 9 + 4 , ' ' , STR_PAD_LEFT ) . " | " . str_pad ('OP/SEC ' , 9 + 4 , ' ' , STR_PAD_LEFT ) . " | " . str_pad ('OP/SEC/MHz ' , 9 + 7 , ' ' , STR_PAD_LEFT ) . " | " . str_pad ('MEMORY ' , 10 , ' ' , STR_PAD_LEFT ) . "\n"
2044
2078
. "$ line \n" . $ flushStr ;
2045
2079
flush ();
@@ -2055,7 +2089,10 @@ function print_results_common()
2055
2089
echo str_pad ($ testName , $ padLabel ) . " : " ;
2056
2090
list ($ resultSec , $ resultSecFmt , $ resultOps , $ resultOpMhz , $ memory ) = $ user ();
2057
2091
$ total += $ resultSec ;
2058
- echo str_pad ($ resultSecFmt , 9 , ' ' , STR_PAD_LEFT ) . " sec | " . str_pad ($ resultOps , 9 , ' ' , STR_PAD_LEFT ) . "Op/s | " . str_pad ($ resultOpMhz , 9 , ' ' , STR_PAD_LEFT ) . "Ops/MHz | " . str_pad ($ memory , 10 , ' ' , STR_PAD_LEFT ) . "\n" ;
2092
+ if ($ printRaw )
2093
+ echo str_pad ($ resultSecFmt , 9 , ' ' , STR_PAD_LEFT ) . " | " . str_pad ($ resultOps , 9 , ' ' , STR_PAD_LEFT ) . " | " . str_pad ($ resultOpMhz , 9 , ' ' , STR_PAD_LEFT ) . " | " . str_pad ($ memory , 10 , ' ' , STR_PAD_LEFT ) . "\n" ;
2094
+ else
2095
+ echo str_pad ($ resultSecFmt , 9 , ' ' , STR_PAD_LEFT ) . " sec | " . str_pad ($ resultOps , 9 , ' ' , STR_PAD_LEFT ) . "Op/s | " . str_pad ($ resultOpMhz , 9 , ' ' , STR_PAD_LEFT ) . "Ops/MHz | " . str_pad ($ memory , 10 , ' ' , STR_PAD_LEFT ) . "\n" ;
2059
2096
echo $ flushStr ;
2060
2097
flush ();
2061
2098
}
@@ -2064,14 +2101,19 @@ function print_results_common()
2064
2101
list ($ resultSec , $ resultSecFmt , $ resultOps , $ resultOpMhz , $ memory ) = format_result_test ($ total , $ totalOps , 0 );
2065
2102
2066
2103
echo "$ line \n"
2067
- . str_pad ("Total: " , $ padLabel ) . " : " ;
2068
- echo str_pad ($ resultSecFmt , 9 , ' ' , STR_PAD_LEFT ) . " sec | " . str_pad ($ resultOps , 9 , ' ' , STR_PAD_LEFT ) . "Op/s | " . str_pad ($ resultOpMhz , 9 , ' ' , STR_PAD_LEFT ) . "Ops/MHz | " . "\n" ;
2069
- echo str_pad ("Current PHP memory usage: " , $ padLabel ) . " : " . str_pad (convert (mymemory_usage ()), 12 , ' ' , STR_PAD_LEFT ) . "\n"
2104
+ . str_pad ("Total: " , $ padLabel ) . " : " ;
2105
+ if ($ printRaw ) {
2106
+ echo str_pad ($ resultSecFmt , 9 , ' ' , STR_PAD_LEFT ) . " | " . str_pad ($ resultOps , 9 , ' ' , STR_PAD_LEFT ) . " | " . str_pad ($ resultOpMhz , 9 , ' ' , STR_PAD_LEFT ) . " | " . "\n" ;
2107
+ echo str_pad ("Current PHP memory usage: " , $ padLabel ) . " : " . str_pad (mymemory_usage (), 12 , ' ' , STR_PAD_LEFT ) . "\n" ;
2108
+ } else {
2109
+ echo str_pad ($ resultSecFmt , 9 , ' ' , STR_PAD_LEFT ) . " sec | " . str_pad ($ resultOps , 9 , ' ' , STR_PAD_LEFT ) . "Op/s | " . str_pad ($ resultOpMhz , 9 , ' ' , STR_PAD_LEFT ) . "Ops/MHz | " . "\n" ;
2110
+ echo str_pad ("Current PHP memory usage: " , $ padLabel ) . " : " . str_pad (convert (mymemory_usage ()), 12 , ' ' , STR_PAD_LEFT ) . "\n"
2070
2111
// php-4 don't have peak_usage function
2071
2112
. (function_exists ('memory_get_peak_usage ' )
2072
2113
? str_pad ("Peak PHP memory usage: " , $ padLabel ) . " : " . str_pad (convert (memory_get_peak_usage ()), 12 , ' ' , STR_PAD_LEFT ) . "\n"
2073
2114
: ''
2074
2115
);
2116
+ }
2075
2117
2076
2118
echo "$ line \n" ;
2077
2119
echo str_pad ("End " , $ padLabel ) . " : " . date ("Y-m-d H:i:s " ) . "\n" ;
0 commit comments