1010# Author : Sergey Dryabzhinsky #
1111# Company : Rusoft Ltd, Russia #
1212# Date : May 29, 2025 #
13- # Version : 1.0.60 -dev #
13+ # Version : 1.0.61 -dev #
1414# License : Creative Commons CC-BY license #
1515# Website : https://github.com/rusoft/php-simple-benchmark-script #
1616# Website : https://gitea.rusoft.ru/open-source/php-simple-benchmark-script #
2020
2121include_once ("php-options.php " );
2222
23- $ scriptVersion = '1.0.60 -dev ' ;
23+ $ scriptVersion = '1.0.61 -dev ' ;
2424
2525// Special string to flush buffers, nginx for example
2626$ flushStr = '<!-- ' .str_repeat (" " , 8192 ).' --> ' ;
105105if (file_exists ('UUID.php ' ) && PHP_VERSION >= '5.0.0 ' ) {
106106 @include_once ("php-uuid.inc " );
107107}
108+ if ( PHP_VERSION >= '5.0.0 ' ) {
109+
110+ if (file_exists ('kvstorage-mem.inc ' )) {
111+ @include_once ("kv-memory.inc " );
112+ }
113+ if (file_exists ('kvstorage-xcache.inc ' ) && extension_loaded ('xCache ' )) {
114+ @include_once ("kv-xcache.inc " );
115+ }
116+ if (file_exists ('kvstorage-apcu.inc ' ) && extension_loaded ('apcu ' )) {
117+ @include_once ("kv-apcu.inc " );
118+ }
119+ if (file_exists ('kvstorage-shmop.inc ' ) && extension_loaded ('shmop ' )) {
120+ @include_once ("kv-shmop.inc " );
121+ }
122+ if (file_exists ('kvstorage-memcache.inc ' ) && extension_loaded ('memcache ' )) {
123+ @include_once ("kv-memcache.inc " );
124+ }
125+ if (file_exists ('kvstorage-redis.inc ' ) && extension_loaded ('redis ' )) {
126+ @include_once ("kv-redis.inc " );
127+ }
128+ }// php>=5.0
129+
108130if (extension_loaded ('uuid ' )) {
109131 @include_once ("mod-uuid.inc " );
110132}
@@ -432,7 +454,7 @@ function gethostname() {
432454 . ' -I|--system-info - output system info but do not run tests and exit ' . PHP_EOL
433455 . ' -m|--memory-limit <Mb> - set memory_limit value in Mb, defaults to 130 (Mb) ' . PHP_EOL
434456 . ' -t|--time-limit <sec> - set max_execution_time value in seconds, defaults to 600 (sec) ' . PHP_EOL
435- . ' -T|--run-test <name > - run selected tests, test names from --list-tests output, can be defined multiple times ' . PHP_EOL
457+ . ' -T|--run-test <pattern > - run selected tests, test names from --list-tests output, can be defined multiple times ' . PHP_EOL
436458 . ' -S|--skip-test <pattern> - skip selected tests, test names pattern to match name from --list-tests output, can be defined multiple times ' . PHP_EOL
437459 . PHP_EOL
438460 . 'Example: php ' . basename (__FILE__ ) . ' -m=64 -t=30 ' . PHP_EOL
@@ -456,7 +478,7 @@ function gethostname() {
456478 . ' -I - output system info but do not run tests and exit ' . PHP_EOL
457479 . ' -m <Mb> - set memory_limit value in Mb, defaults to 130 (Mb) ' . PHP_EOL
458480 . ' -t <sec> - set max_execution_time value in seconds, defaults to 600 (sec) ' . PHP_EOL
459- . ' -T <name > - run selected tests, test names from -L output, can be defined multiple times ' . PHP_EOL
481+ . ' -T <pattern > - run selected tests, test names from -L output, can be defined multiple times ' . PHP_EOL
460482 . ' -S <pattern> - skip selected tests, test names pattern to match name from -L output, can be defined multiple times ' . PHP_EOL
461483 . PHP_EOL
462484 . 'Example: php ' . basename (__FILE__ ) . ' -m 64 -t 30 ' . PHP_EOL
@@ -567,14 +589,19 @@ function gethostname() {
567589$ tz = ini_get ('date.timezone ' );
568590if (!$ tz ) ini_set ('date.timezone ' , 'Europe/Moscow ' );
569591
570- ini_set ('display_errors ' , 0 );
571592@ini_set ('error_log ' , null );
572593ini_set ('implicit_flush ' , 1 );
573594ini_set ('output_buffering ' , 0 );
574595ob_implicit_flush (1 );
575596
576- // Disable explicit error reporting
577- error_reporting (E_ERROR | E_WARNING | E_PARSE );
597+ if ($ debugMode ){
598+ ini_set ('display_errors ' , 1 );
599+ error_reporting (E_ERROR | E_WARNING | E_PARSE );
600+ } else {
601+ ini_set ('display_errors ' , 0 );
602+ // Disable explicit error reporting
603+ error_reporting (E_ERROR | E_WARNING | E_PARSE );
604+ }
578605
579606// Check XDebug
580607$ xdebug = (int )ini_get ('xdebug.default_enable ' );
@@ -774,6 +801,12 @@ function gethostname() {
774801 '37_02_php8_str_ccontains_simulate ' => 100000 ,
775802 '38_01_php_uuid ' => 1000000 ,
776803 '38_02_mod_uuid ' => 1000000 ,
804+ '39_01_kvstorage_memory ' => 500000 ,
805+ '39_02_kvstorage_xcache ' => 500000 ,
806+ '39_03_kvstorage_apcu ' => 500000 ,
807+ '39_04_kvstorage_shmop ' => 500000 ,
808+ '39_05_kvstorage_memcache ' => 500000 ,
809+ '39_06_kvstorage_redis ' => 500000 ,
777810);
778811// Should not be more than X Mb
779812// Different PHP could use different amount of memory
@@ -832,6 +865,12 @@ function gethostname() {
832865 '37_02_php8_str_ccontains_simulate ' => 4 ,
833866 '38_01_php_uuid ' => 4 ,
834867 '38_02_mod_uuid ' => 4 ,
868+ '39_01_kvstorage_memory ' => 3 ,
869+ '39_02_kvstorage_xcache ' => 2 ,
870+ '39_03_kvstorage_apcu ' => 47 ,
871+ '39_04_kvstorage_shmop ' => 70 ,
872+ '39_05_kvstorage_memcache ' => 47 ,
873+ '39_06_kvstorage_redis ' => 47 ,
835874);
836875
837876/** ---------------------------------- Common functions -------------------------------------------- */
@@ -1514,6 +1553,29 @@ function format_result_test($diffSeconds, $opCount, $memory = 0)
15141553$ availableFunctions =$ functions ['user ' ];
15151554sort ($ availableFunctions );
15161555
1556+ // fiter in tests
1557+ function filter_in_name_by_pattern ($ key )
1558+ {
1559+ global $ selectedTests , $ debugMode , $ availableFunctions ;
1560+ $ var = $ availableFunctions [$ key ];
1561+ $ ret = 0 ;
1562+ foreach ($ selectedTests as $ pattern ){
1563+ // simple test - str in name
1564+ $ c =strpos ($ var ,$ pattern );
1565+ if ($ debugMode ) {
1566+ $ d =var_export ($ c ,true );
1567+ print ("Search ' $ pattern' inside ' $ var': $ d \n" );
1568+ }
1569+ if ($ c !==false ) {
1570+ $ ret = 1 ;
1571+ break ;
1572+ };
1573+ }
1574+ //nothing found - skipping
1575+ if ($ debugMode ) print ("Will return $ ret \n" );
1576+ if (!$ ret ) unset($ availableFunctions [$ key ]);
1577+ return $ ret ;
1578+ }
15171579// fiter out tests
15181580function filter_out_name_by_pattern ($ key )
15191581{
@@ -1537,6 +1599,7 @@ function filter_out_name_by_pattern($key)
15371599 if (!$ ret ) unset($ availableFunctions [$ key ]);
15381600 return $ ret ;
15391601}
1602+ if ($ selectedTests ) array_filter ($ availableFunctions , "filter_in_name_by_pattern " ,ARRAY_FILTER_USE_KEY );
15401603if ($ skipTests ) array_filter ($ availableFunctions , "filter_out_name_by_pattern " ,ARRAY_FILTER_USE_KEY );
15411604/** ------------------------------- Early checks ------------------------------- */
15421605
@@ -1588,7 +1651,7 @@ function filter_out_name_by_pattern($key)
15881651 $ has_json = "{$ colorRed }no {$ colorReset }" ;
15891652 if ($ printJson ) {
15901653 print_pre ("{$ colorRed }<<< ERROR >>> {$ colorReset } Extension 'json' is mandatory for JSON output! " );
1591- print ("\"messages_count \": {$ messagesCnt }, \n" );
1654+ print ("\"messag0es_count \": {$ messagesCnt }, \n" );
15921655 print ("\"end \":true \n} " . PHP_EOL );
15931656 exit (-1 );
15941657 }
@@ -1602,14 +1665,38 @@ function filter_out_name_by_pattern($key)
16021665if (extension_loaded ('Zend OPcache ' )) {
16031666 $ has_opcache = "{$ colorYellow }yes {$ colorReset }" ;
16041667}
1605- $ has_xcache = "{$ colorGreen }no {$ colorReset }" ;
1668+ $ has_xcache = "{$ colorYellow }no {$ colorReset }" ;
16061669if (extension_loaded ('XCache ' )) {
16071670 $ has_xcache = "{$ colorYellow }yes {$ colorReset }" ;
16081671}
16091672$ has_apc = "{$ colorGreen }no {$ colorReset }" ;
16101673if (extension_loaded ('apc ' )) {
16111674 $ has_apc = "{$ colorYellow }yes {$ colorReset }" ;
16121675}
1676+ $ has_apcu = "{$ colorYellow }no {$ colorReset }" ;
1677+ if (extension_loaded ('apcu ' )) {
1678+ $ has_apcu = "{$ colorGreen }yes {$ colorReset }" ;
1679+ }
1680+ $ has_shmop = "{$ colorYellow }no {$ colorReset }" ;
1681+ if (extension_loaded ('shmop ' )) {
1682+ $ has_shmop = "{$ colorGreen }yes {$ colorReset }" ;
1683+ }
1684+ $ has_memcache = "{$ colorYellow }no {$ colorReset }" ;
1685+ if (extension_loaded ('memcache ' )) {
1686+ $ has_memcache = "{$ colorGreen }yes {$ colorReset }" ;
1687+ include_once ('memcache.inc ' );
1688+ $ v =get_memcached_version ();
1689+ if ($ v ) define ('MEMCACHE_VERSION ' ,$ v );
1690+ else define ('MEMCACHE_VERSION ' ,'-.-.- ' );
1691+ }
1692+ $ has_redis = "{$ colorYellow }no {$ colorReset }" ;
1693+ if (extension_loaded ('memcache ' )) {
1694+ $ has_redis = "{$ colorGreen }yes {$ colorReset }" ;
1695+ include_once ('redis.inc ' );
1696+ $ v =get_redis_version ();
1697+ if ($ v ) define ('REDIS_VERSION ' ,$ v );
1698+ else define ('REDIS_VERSION ' ,'-.-.- ' );
1699+ }
16131700$ has_eacc = "{$ colorGreen }no {$ colorReset }" ;
16141701if (extension_loaded ('eAccelerator ' )) {
16151702 $ has_eacc = "{$ colorYellow }yes {$ colorReset }" ;
@@ -1713,7 +1800,7 @@ function print_results_common()
17131800 global $ flushStr , $ has_apc , $ has_pcre , $ has_intl , $ has_json , $ has_simplexml , $ has_dom , $ has_mbstring , $ has_opcache , $ has_xcache ;
17141801 global $ has_gd , $ has_imagick , $ has_igb , $ has_msg , $ has_jsond , $ has_jsond_as_json ;
17151802 global $ has_zlib , $ has_uuid , $ has_gzip , $ has_bz2 , $ has_lz4 , $ has_snappy , $ has_zstd , $ has_brotli ;
1716- global $ opcache , $ has_eacc , $ has_xdebug , $ xcache , $ apcache , $ eaccel , $ xdebug , $ xdbg_mode , $ obd_set , $ mbover ;
1803+ global $ has_apcu , $ has_shmop , $ has_memcache , $ has_redis , $ opcache , $ has_eacc , $ has_xdebug , $ xcache , $ apcache , $ eaccel , $ xdebug , $ xdbg_mode , $ obd_set , $ mbover ;
17171804 global $ showOnlySystemInfo , $ padLabel , $ functions , $ runOnlySelectedTests , $ selectedTests , $ totalOps ;
17181805 global $ colorGreen , $ colorReset , $ colorRed ;
17191806
@@ -1749,6 +1836,10 @@ function print_results_common()
17491836 . str_pad ("-optional-> " , $ padInfo , ' ' , STR_PAD_LEFT ) . "\n"
17501837 . str_pad ("gd " , $ padInfo , ' ' , STR_PAD_LEFT ) . " : $ has_gd: version: " . GD_VERSION ."\n"
17511838 . str_pad ("imagick " , $ padInfo , ' ' , STR_PAD_LEFT ) . " : $ has_imagick: version: " .IMG_VERSION ."\n"
1839+ . str_pad ("apcu " , $ padInfo , ' ' , STR_PAD_LEFT ) . " : $ has_apcu; \n"
1840+ . str_pad ("shmop " , $ padInfo , ' ' , STR_PAD_LEFT ) . " : $ has_shmop; \n"
1841+ . str_pad ("memcache " , $ padInfo , ' ' , STR_PAD_LEFT ) . " : $ has_memcache, version: " .MEMCACHE_VERSION ."; \n"
1842+ . str_pad ("redis " , $ padInfo , ' ' , STR_PAD_LEFT ) . " : $ has_redis, version: " .REDIS_VERSION ."; \n"
17521843 . str_pad ("-alternative-> " , $ padInfo , ' ' , STR_PAD_LEFT ) . "\n"
17531844 . str_pad ("igbinary " , $ padInfo , ' ' , STR_PAD_LEFT ) . " : $ has_igb \n"
17541845 . str_pad ("msgpack " , $ padInfo , ' ' , STR_PAD_LEFT ) . " : $ has_msg \n"
@@ -1785,11 +1876,11 @@ function print_results_common()
17851876 foreach ($ availableFunctions as $ user ) {
17861877 if (strpos ($ user , 'test_ ' ) === 0 ) {
17871878 $ testName = str_replace ('test_ ' , '' , $ user );
1788- if ($ runOnlySelectedTests ) {
1879+ /* if ($runOnlySelectedTests) {
17891880 if (!in_array($testName, $selectedTests)) {
17901881 continue;
17911882 }
1792- }
1883+ }*/
17931884 echo str_pad ($ testName , $ padLabel ) . " : " ;
17941885 list ($ resultSec , $ resultSecFmt , $ resultOps , $ resultOpMhz , $ memory ) = $ user ();
17951886 $ total += $ resultSec ;
0 commit comments