10
10
# Author : Sergey Dryabzhinsky #
11
11
# Company : Rusoft Ltd, Russia #
12
12
# Date : May 29, 2025 #
13
- # Version : 1.0.60 -dev #
13
+ # Version : 1.0.61 -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.60 -dev ' ;
23
+ $ scriptVersion = '1.0.61 -dev ' ;
24
24
25
25
// Special string to flush buffers, nginx for example
26
26
$ flushStr = '<!-- ' .str_repeat (" " , 8192 ).' --> ' ;
105
105
if (file_exists ('UUID.php ' ) && PHP_VERSION >= '5.0.0 ' ) {
106
106
@include_once ("php-uuid.inc " );
107
107
}
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
+
108
130
if (extension_loaded ('uuid ' )) {
109
131
@include_once ("mod-uuid.inc " );
110
132
}
@@ -432,7 +454,7 @@ function gethostname() {
432
454
. ' -I|--system-info - output system info but do not run tests and exit ' . PHP_EOL
433
455
. ' -m|--memory-limit <Mb> - set memory_limit value in Mb, defaults to 130 (Mb) ' . PHP_EOL
434
456
. ' -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
436
458
. ' -S|--skip-test <pattern> - skip selected tests, test names pattern to match name from --list-tests output, can be defined multiple times ' . PHP_EOL
437
459
. PHP_EOL
438
460
. 'Example: php ' . basename (__FILE__ ) . ' -m=64 -t=30 ' . PHP_EOL
@@ -456,7 +478,7 @@ function gethostname() {
456
478
. ' -I - output system info but do not run tests and exit ' . PHP_EOL
457
479
. ' -m <Mb> - set memory_limit value in Mb, defaults to 130 (Mb) ' . PHP_EOL
458
480
. ' -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
460
482
. ' -S <pattern> - skip selected tests, test names pattern to match name from -L output, can be defined multiple times ' . PHP_EOL
461
483
. PHP_EOL
462
484
. 'Example: php ' . basename (__FILE__ ) . ' -m 64 -t 30 ' . PHP_EOL
@@ -567,14 +589,19 @@ function gethostname() {
567
589
$ tz = ini_get ('date.timezone ' );
568
590
if (!$ tz ) ini_set ('date.timezone ' , 'Europe/Moscow ' );
569
591
570
- ini_set ('display_errors ' , 0 );
571
592
@ini_set ('error_log ' , null );
572
593
ini_set ('implicit_flush ' , 1 );
573
594
ini_set ('output_buffering ' , 0 );
574
595
ob_implicit_flush (1 );
575
596
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
+ }
578
605
579
606
// Check XDebug
580
607
$ xdebug = (int )ini_get ('xdebug.default_enable ' );
@@ -774,6 +801,12 @@ function gethostname() {
774
801
'37_02_php8_str_ccontains_simulate ' => 100000 ,
775
802
'38_01_php_uuid ' => 1000000 ,
776
803
'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 ,
777
810
);
778
811
// Should not be more than X Mb
779
812
// Different PHP could use different amount of memory
@@ -832,6 +865,12 @@ function gethostname() {
832
865
'37_02_php8_str_ccontains_simulate ' => 4 ,
833
866
'38_01_php_uuid ' => 4 ,
834
867
'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 ,
835
874
);
836
875
837
876
/** ---------------------------------- Common functions -------------------------------------------- */
@@ -1514,6 +1553,29 @@ function format_result_test($diffSeconds, $opCount, $memory = 0)
1514
1553
$ availableFunctions =$ functions ['user ' ];
1515
1554
sort ($ availableFunctions );
1516
1555
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
+ }
1517
1579
// fiter out tests
1518
1580
function filter_out_name_by_pattern ($ key )
1519
1581
{
@@ -1537,6 +1599,7 @@ function filter_out_name_by_pattern($key)
1537
1599
if (!$ ret ) unset($ availableFunctions [$ key ]);
1538
1600
return $ ret ;
1539
1601
}
1602
+ if ($ selectedTests ) array_filter ($ availableFunctions , "filter_in_name_by_pattern " ,ARRAY_FILTER_USE_KEY );
1540
1603
if ($ skipTests ) array_filter ($ availableFunctions , "filter_out_name_by_pattern " ,ARRAY_FILTER_USE_KEY );
1541
1604
/** ------------------------------- Early checks ------------------------------- */
1542
1605
@@ -1588,7 +1651,7 @@ function filter_out_name_by_pattern($key)
1588
1651
$ has_json = "{$ colorRed }no {$ colorReset }" ;
1589
1652
if ($ printJson ) {
1590
1653
print_pre ("{$ colorRed }<<< ERROR >>> {$ colorReset } Extension 'json' is mandatory for JSON output! " );
1591
- print ("\"messages_count \": {$ messagesCnt }, \n" );
1654
+ print ("\"messag0es_count \": {$ messagesCnt }, \n" );
1592
1655
print ("\"end \":true \n} " . PHP_EOL );
1593
1656
exit (-1 );
1594
1657
}
@@ -1602,14 +1665,38 @@ function filter_out_name_by_pattern($key)
1602
1665
if (extension_loaded ('Zend OPcache ' )) {
1603
1666
$ has_opcache = "{$ colorYellow }yes {$ colorReset }" ;
1604
1667
}
1605
- $ has_xcache = "{$ colorGreen }no {$ colorReset }" ;
1668
+ $ has_xcache = "{$ colorYellow }no {$ colorReset }" ;
1606
1669
if (extension_loaded ('XCache ' )) {
1607
1670
$ has_xcache = "{$ colorYellow }yes {$ colorReset }" ;
1608
1671
}
1609
1672
$ has_apc = "{$ colorGreen }no {$ colorReset }" ;
1610
1673
if (extension_loaded ('apc ' )) {
1611
1674
$ has_apc = "{$ colorYellow }yes {$ colorReset }" ;
1612
1675
}
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
+ }
1613
1700
$ has_eacc = "{$ colorGreen }no {$ colorReset }" ;
1614
1701
if (extension_loaded ('eAccelerator ' )) {
1615
1702
$ has_eacc = "{$ colorYellow }yes {$ colorReset }" ;
@@ -1713,7 +1800,7 @@ function print_results_common()
1713
1800
global $ flushStr , $ has_apc , $ has_pcre , $ has_intl , $ has_json , $ has_simplexml , $ has_dom , $ has_mbstring , $ has_opcache , $ has_xcache ;
1714
1801
global $ has_gd , $ has_imagick , $ has_igb , $ has_msg , $ has_jsond , $ has_jsond_as_json ;
1715
1802
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 ;
1717
1804
global $ showOnlySystemInfo , $ padLabel , $ functions , $ runOnlySelectedTests , $ selectedTests , $ totalOps ;
1718
1805
global $ colorGreen , $ colorReset , $ colorRed ;
1719
1806
@@ -1749,6 +1836,10 @@ function print_results_common()
1749
1836
. str_pad ("-optional-> " , $ padInfo , ' ' , STR_PAD_LEFT ) . "\n"
1750
1837
. str_pad ("gd " , $ padInfo , ' ' , STR_PAD_LEFT ) . " : $ has_gd: version: " . GD_VERSION ."\n"
1751
1838
. 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"
1752
1843
. str_pad ("-alternative-> " , $ padInfo , ' ' , STR_PAD_LEFT ) . "\n"
1753
1844
. str_pad ("igbinary " , $ padInfo , ' ' , STR_PAD_LEFT ) . " : $ has_igb \n"
1754
1845
. str_pad ("msgpack " , $ padInfo , ' ' , STR_PAD_LEFT ) . " : $ has_msg \n"
@@ -1785,11 +1876,11 @@ function print_results_common()
1785
1876
foreach ($ availableFunctions as $ user ) {
1786
1877
if (strpos ($ user , 'test_ ' ) === 0 ) {
1787
1878
$ testName = str_replace ('test_ ' , '' , $ user );
1788
- if ($ runOnlySelectedTests ) {
1879
+ /* if ($runOnlySelectedTests) {
1789
1880
if (!in_array($testName, $selectedTests)) {
1790
1881
continue;
1791
1882
}
1792
- }
1883
+ }*/
1793
1884
echo str_pad ($ testName , $ padLabel ) . " : " ;
1794
1885
list ($ resultSec , $ resultSecFmt , $ resultOps , $ resultOpMhz , $ memory ) = $ user ();
1795
1886
$ total += $ resultSec ;
0 commit comments