Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f1c46b3

Browse files
Merge pull request 'issue-19-kv-mysql-pgsql' (#23) from issue-19-kv-mysql-pgsql into master
Reviewed-on: https://gitea.rusoft.ru/open-source/php-simple-benchmark-script/pulls/23
2 parents 6cc136c + 7c21887 commit f1c46b3

31 files changed

+889
-48
lines changed

‎CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ChangeLog
22

3+
@ 2025年06月13日, v1.0.66
4+
5+
* Added simple tests for mysql,mysqli,pgsql
6+
37
@ 2025年06月07日, v1.0.65
48

59
* Added simple test for session

‎README.en.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Required modules for full php testing:
2727
- memcache
2828
- redis
2929
- sqlite3
30+
- mysql/mysqli
31+
- pgsql
3032

3133
Usually they are already installed or "compiled" in php.
3234

‎README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
- memcache
2828
- redis
2929
- sqlite3
30+
- mysql/mysqli
31+
- pgsql
3032

3133
Обычно они уже установлены или "вкомпилированны" в php.
3234

‎bench.php

Lines changed: 88 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Author : Sergey Dryabzhinsky #
1111
# Company : Rusoft Ltd, Russia #
1212
# Date : Jun 7, 2025 #
13-
# Version : 1.0.65 #
13+
# Version : 1.0.66 #
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 #
@@ -20,7 +20,7 @@
2020

2121
include_once("php-options.php");
2222

23-
$scriptVersion = '1.0.65';
23+
$scriptVersion = '1.0.66';
2424

2525
// Special string to flush buffers, nginx for example
2626
$flushStr = '<!-- '.str_repeat("", 8192).' -->';
@@ -134,6 +134,19 @@
134134
if (file_exists('kvstorage-redis.inc') && extension_loaded('redis')) {
135135
@include_once("kv-redis.inc");
136136
}
137+
if (file_exists('kvstorage-pgsql.inc') && extension_loaded('pgsql')) {
138+
@include_once("kv-pgsql.inc");
139+
}
140+
if (file_exists('kvstorage-mysql.inc') && extension_loaded('mysql')) {
141+
@include_once("kv-mysql-myisam.inc");
142+
@include_once("kv-mysql-innodb.inc");
143+
@include_once("kv-mysql-memory.inc");
144+
}
145+
if (file_exists('kvstorage-mysqli.inc') && extension_loaded('mysqli')) {
146+
@include_once("kv-mysqli-myisam.inc");
147+
@include_once("kv-mysqli-innodb.inc");
148+
@include_once("kv-mysqli-memory.inc");
149+
}
137150
}// php>=5.0
138151
if ( PHP_VERSION >= '5.3.0') {
139152
if (file_exists('kvstorage-sqlite3.inc') && extension_loaded('sqlite3')) {
@@ -734,22 +747,22 @@ function gethostname() {
734747
$loopMaxPhpTimesMHz = 3500;
735748
// How much time needed for tests on this machine
736749
$loopMaxPhpTimes = array(
737-
'4.4' => 2099,
738-
'5.2' => 839,
739-
'5.3' => 1235,
740-
'5.4' => 1510,
741-
'5.5' => 802,
742-
'5.6' => 1337,
743-
'7.0' => 672,
744-
'7.1' => 669,
745-
'7.2' => 662,
746-
'7.3' => 586,
747-
'7.4' => 659,
748-
'8.0' => 676,
749-
'8.1' => 450,
750-
'8.2' => 427,
751-
'8.3' => 582,
752-
'8.4' => 529
750+
'4.4' => 1117,
751+
'5.2' => 1210,
752+
'5.3' => 2259,
753+
'5.4' => 4155,
754+
'5.5' => 4588,
755+
'5.6' => 4481,
756+
'7.0' => 3224,
757+
'7.1' => 3288,
758+
'7.2' => 2974,
759+
'7.3' => 3451,
760+
'7.4' => 3065,
761+
'8.0' => 3198,
762+
'8.1' => 4099,
763+
'8.2' => 2971,
764+
'8.3' => 3001,
765+
'8.4' => 4535
753766
);
754767
// Simple and fast test times, used to adjust all test times and limits
755768
$dumbTestMaxPhpTimes = array(
@@ -792,6 +805,7 @@ function gethostname() {
792805
'12_igb_unserialize' => 1300000,
793806
'11_msgpack_pack' => 1300000,
794807
'12_msgpack_unpack' => 1300000,
808+
'13_array_fill' => 250,
795809
'13_array_loop' => 250,
796810
'14_array_loop' => 250,
797811
'15_clean_loops' => 200000000,
@@ -819,10 +833,10 @@ function gethostname() {
819833
'36_01_zlib_deflate_compress' => 500000,
820834
'36_02_zlib_gzip_compress' => 500000,
821835
'36_bzip2_compress' => 50000,
822-
'36_lz4_compress' => 5000000,
823-
'36_snappy_compress' => 5000000,
824-
'36_zstd_compress' => 5000000,
825-
'36_brotli_compress' => 1000000,
836+
'36_lz4_compress' => 500000,
837+
'36_snappy_compress' => 500000,
838+
'36_zstd_compress' => 500000,
839+
'36_brotli_compress' => 100000,
826840
'37_01_php8_str_contains' => 100000,
827841
'37_02_php8_str_contains_emulate' => 100000,
828842
'38_01_php_uuid' => 1000000,
@@ -846,6 +860,13 @@ function gethostname() {
846860
'42_ctype_isdigit' => 10000000,
847861
'43_iconv_translit' => 10000000,
848862
'44_session_time' => 100000,
863+
'45_01_kvs_mysql_myisam' => 1000000,
864+
'45_02_kvs_mysql_innodb' => 1000000,
865+
'45_03_kvs_mysql_memory' => 1000000,
866+
'46_01_kvs_mysqli_myisam' => 1000000,
867+
'46_02_kvs_mysqli_innodb' => 1000000,
868+
'46_03_kvs_mysqli_memory' => 1000000,
869+
'47_kvs_pgsql' => 100000,
849870
);
850871
// Should not be more than X Mb
851872
// Different PHP could use different amount of memory
@@ -868,7 +889,8 @@ function gethostname() {
868889
'11_igb_serialize' => 4,
869890
'12_igb_unserialize' => 4,
870891
// php-5.3
871-
'13_array_loop' => 54,
892+
'13_array_fill' => 55,
893+
'13_array_loop' => 61,
872894
'14_array_loop' => 62,
873895
// opcache, php-7.4
874896
'15_clean_loops' => 14,
@@ -923,6 +945,13 @@ function gethostname() {
923945
'42_ctype_isdigit' => 4,
924946
'43_iconv_translit' => 4,
925947
'44_session_time' => 4,
948+
'45_01_kvs_mysql_myisam' => 4,
949+
'45_02_kvs_mysql_innodb' => 4,
950+
'45_03_kvs_mysql_memory' => 4,
951+
'46_01_kvs_mysqli_myisam' => 4,
952+
'46_02_kvs_mysqli_innodb' => 4,
953+
'46_03_kvs_mysqli_memory' => 4,
954+
'47_kvs_pgsql' => 4,
926955
);
927956

928957
/** ---------------------------------- Common functions -------------------------------------------- */
@@ -1753,6 +1782,30 @@ function filter_out_name_by_pattern($key)
17531782
if ($v) define('REDIS_VERSION',$v);
17541783
else define('REDIS_VERSION','-.-.-');
17551784
}
1785+
$has_mysql = "{$colorYellow}no{$colorReset}";
1786+
if (extension_loaded('mysql')) {
1787+
$has_mysql = "{$colorGreen}yes{$colorReset}";
1788+
include_once('mysql.inc');
1789+
$v=get_mysql_version();
1790+
if ($v) define('MYSQL_VERSION',$v);
1791+
else define('MYSQL_VERSION','-.-.-');
1792+
}
1793+
$has_pgsql = "{$colorYellow}no{$colorReset}";
1794+
if (extension_loaded('pgsql')) {
1795+
$has_pgsql = "{$colorGreen}yes{$colorReset}";
1796+
include_once('pgsql.inc');
1797+
$v=get_pgsql_version();
1798+
if ($v) define('PGSQL_VERSION',$v);
1799+
else define('PGSQL_VERSION','-.-.-');
1800+
}
1801+
$has_mysqli = "{$colorYellow}no{$colorReset}";
1802+
if (extension_loaded('mysqli')) {
1803+
$has_mysqli = "{$colorGreen}yes{$colorReset}";
1804+
include_once('mysqli.inc');
1805+
$v=get_mysqli_version();
1806+
if ($v) define('MYSQLI_VERSION',$v);
1807+
else define('MYSQLI_VERSION','-.-.-');
1808+
}
17561809
$has_sqlite3 = "{$colorYellow}no{$colorReset}";
17571810
if (extension_loaded('sqlite3')) {
17581811
$has_sqlite3 = "{$colorGreen}yes{$colorReset}";
@@ -1882,10 +1935,14 @@ function filter_out_name_by_pattern($key)
18821935
}
18831936

18841937
if (!defined('PCRE_VERSION')) define('PCRE_VERSION', '-.--');
1938+
if (!defined('ICONV_VERSION')) define('ICONV_VERSION', '-.--');
18851939
if (!defined('ZLIB_VERSION')) define('ZLIB_VERSION', '-.-.-');
18861940
if (!defined('MEMCACHE_VERSION')) define('MEMCACHE_VERSION', '-.-.-');
18871941
if (!defined('REDIS_VERSION')) define('REDIS_VERSION', '-.-.-');
18881942
if (!defined('SQLITE3_VERSION')) define('SQLITE3_VERSION', '-.-.-');
1943+
if (!defined('MYSQL_VERSION')) define('MYSQL_VERSION', '-.-.-');
1944+
if (!defined('PGSQL_VERSION')) define('PGSQL_VERSION', '-.-.-');
1945+
if (!defined('MYSQLI_VERSION')) define('MYSQLI_VERSION', '-.-.-');
18891946
if (!defined('LIBXML_DOTTED_VERSION')) define('LIBXML_DOTTED_VERSION', '-.-.-');
18901947
if (!defined('SODIUM_LIBRARY_VERSION')) define('SODIUM_LIBRARY_VERSION', '-.-.-');
18911948
if (!defined('INTL_ICU_VERSION')) define('INTL_ICU_VERSION', '-.-');
@@ -1901,7 +1958,7 @@ function print_results_common()
19011958
global $has_gd, $has_gdgif, $has_gdpng, $has_gdjpg, $has_gdwebp, $has_gdavif;
19021959
global $has_imagick, $has_igb, $has_msg, $has_jsond, $has_jsond_as_json, $has_ctype, $has_iconv, $has_session;
19031960
global $has_zlib, $has_uuid, $has_gzip, $has_bz2, $has_lz4, $has_snappy, $has_zstd, $has_brotli;
1904-
global $has_apcu, $has_shmop, $has_memcache, $has_redis, $has_sodium, $has_sqlite3, $opcache, $has_eacc, $has_xdebug, $xcache, $apcache, $eaccel, $xdebug, $xdbg_mode, $obd_set, $mbover;
1961+
global $has_apcu, $has_shmop, $has_memcache, $has_redis, $has_mysql, $has_pgsql, $has_mysqli, $has_sodium, $has_sqlite3, $opcache, $has_eacc, $has_xdebug, $xcache, $apcache, $eaccel, $xdebug, $xdbg_mode, $obd_set, $mbover;
19051962
global $showOnlySystemInfo, $padLabel, $functions, $runOnlySelectedTests, $selectedTests, $totalOps;
19061963
global $colorGreen, $colorReset, $colorRed;
19071964

@@ -1934,7 +1991,7 @@ function print_results_common()
19341991
. str_pad("simplexml", $padInfo, '', STR_PAD_LEFT) . " : $has_simplexml; libxml version: ".LIBXML_DOTTED_VERSION."\n"
19351992
. str_pad("dom", $padInfo, '', STR_PAD_LEFT) . " : $has_dom\n"
19361993
. str_pad("ctype", $padInfo, '', STR_PAD_LEFT) . " : $has_ctype\n"
1937-
. str_pad("iconv", $padInfo, '', STR_PAD_LEFT) . " : $has_iconv\n"
1994+
. str_pad("iconv", $padInfo, '', STR_PAD_LEFT) . " : $has_iconv; version: ".ICONV_VERSION."\n"
19381995
. str_pad("session", $padInfo, '', STR_PAD_LEFT) . " : $has_session\n"
19391996
. str_pad("intl", $padInfo, '', STR_PAD_LEFT) . " : $has_intl" . ($has_intl == "{$colorGreen}yes{$colorReset}" ? '; icu version: ' . INTL_ICU_VERSION : '')."\n"
19401997
. str_pad("-optional->", $padInfo, '', STR_PAD_LEFT) . "\n"
@@ -1944,11 +2001,14 @@ function print_results_common()
19442001
. str_pad("\t- JPG", $padInfo, '', STR_PAD_LEFT) . " : $has_gdjpg"."\n"
19452002
. str_pad("\t- WEBP", $padInfo, '', STR_PAD_LEFT) . " : $has_gdwebp"."\n"
19462003
. str_pad("\t- AVIF", $padInfo, '', STR_PAD_LEFT) . " : $has_gdavif"."\n"
1947-
. str_pad("imagick", $padInfo, '', STR_PAD_LEFT) . " : $has_imagick: version: ".IMG_VERSION."\n"
1948-
. str_pad("apcu", $padInfo, '', STR_PAD_LEFT) . " : $has_apcu;\n"
2004+
. str_pad("imagick", $padInfo, '', STR_PAD_LEFT) . " : $has_imagick: version: ".IMG_VERSION.";\n"
2005+
. str_pad("apcu", $padInfo, '', STR_PAD_LEFT) . " : $has_apcu\n"
19492006
. str_pad("shmop", $padInfo, '', STR_PAD_LEFT) . " : $has_shmop\n"
19502007
. str_pad("memcache", $padInfo, '', STR_PAD_LEFT) . " : $has_memcache, version: ".MEMCACHE_VERSION.";\n"
19512008
. str_pad("redis", $padInfo, '', STR_PAD_LEFT) . " : $has_redis, version: ".REDIS_VERSION.";\n"
2009+
. str_pad("mysql", $padInfo, '', STR_PAD_LEFT) . " : $has_mysql, version: ".MYSQL_VERSION.";\n"
2010+
. str_pad("pgsql", $padInfo, '', STR_PAD_LEFT) . " : $has_pgsql, version: ".PGSQL_VERSION.";\n"
2011+
. str_pad("mysqli", $padInfo, '', STR_PAD_LEFT) . " : $has_mysqli, version: ".MYSQLI_VERSION.";\n"
19522012
. str_pad("sqlite3", $padInfo, '', STR_PAD_LEFT) . " : $has_sqlite3, version: ".SQLITE3_VERSION.";\n"
19532013
. str_pad("sodium", $padInfo, '', STR_PAD_LEFT) . " : $has_sodium, version: ".SODIUM_LIBRARY_VERSION.";\n"
19542014
. str_pad("-alternative->", $padInfo, '', STR_PAD_LEFT) . "\n"
@@ -1962,7 +2022,7 @@ function print_results_common()
19622022
. str_pad("bz2", $padInfo, '', STR_PAD_LEFT) . " : $has_bz2\n"
19632023
. str_pad("lz4", $padInfo, '', STR_PAD_LEFT) . " : $has_lz4\n"
19642024
. str_pad("snappy", $padInfo, '', STR_PAD_LEFT) . " : $has_snappy\n"
1965-
. str_pad("zstd", $padInfo, '', STR_PAD_LEFT) . " : $has_zstd, version: ".LIBZSTD_VERSION_STRING."\n"
2025+
. str_pad("zstd", $padInfo, '', STR_PAD_LEFT) . " : $has_zstd, version: ".LIBZSTD_VERSION_STRING.";\n"
19662026
. str_pad("brotli", $padInfo, '', STR_PAD_LEFT) . " : $has_brotli\n"
19672027
. str_pad("uuid", $padInfo, '', STR_PAD_LEFT) . " : $has_uuid\n"
19682028
. str_pad("-affecting->", $padInfo, '', STR_PAD_LEFT) . "\n"

‎common.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ function test_13_Array_Fill()
377377
{
378378
global $testsLoopLimits, $arrayDimensionLimit, $totalOps;
379379

380-
$arrayTestLoopLimit = $testsLoopLimits['13_array_loop'];
380+
$arrayTestLoopLimit = $testsLoopLimits['13_array_fill'];
381381
$time_start = get_microtime();
382382
$memory = 0;
383383
for ($n = 0; $n < $arrayTestLoopLimit; ++$n) {

‎compression-zstd.inc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* php test functions for compression by brotli
4+
* Php 5.2+
5+
*/
6+
7+
/** ---------------------------------- Tests functions -------------------------------------------- */
8+
9+
function test_36_zstd_compress()
10+
{
11+
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps, $stringTest;
12+
13+
if (!function_exists('zstd_compress')) {
14+
return $emptyResult;
15+
}
16+
17+
$count = $testsLoopLimits['36_zstd_compress'];
18+
$time_start = get_microtime();
19+
for ($i = 0; $i < $count; $i++) {
20+
$r = zstd_compress($stringTest, 1);
21+
}
22+
$totalOps += $count;
23+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
24+
}

‎kv-apcu.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ function test_39_03_kvstorage_apcu()
3434
}
3535

3636
for ($i = 0; $i < $count; $i++) {
37-
$num = $i / 100.;
37+
$num = number_format($i / 100., 2, '.', '');
3838
$kvstorage->set($i, $num);
3939
$v=$kvstorage->get($i);
40-
if ($v===$num) $kvstorage->del($i);
40+
$kvstorage->del($i);
4141
}
4242
$totalOps += $count;
4343
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());

‎kv-memory.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ function test_39_01_kvstorage_memory()
2424
$time_start = get_microtime();
2525

2626
for ($i = 0; $i < $count; $i++) {
27-
$num = $i / 100.;
27+
$num =number_format( $i / 100., 2, '.', '');
2828
$kvstorage->set($i, $num);
2929
$v=$kvstorage->get($i);
30-
if ($v===$num) $kvstorage->del($i);
30+
$kvstorage->del($i);
3131
}
3232
$totalOps += $count;
3333
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());

‎kv-mysql-innodb.inc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* php safe options - only tests mod mysql
4+
* Php 4.0+
5+
*/
6+
7+
/** ---------------------------------- Tests functions -------------------------------------------- */
8+
9+
// ------------------------- INTL tests -----------------------
10+
11+
/**
12+
* @since 4.0
13+
*/
14+
function test_45_02_kvs_mysql_innodb()
15+
{
16+
global $testsLoopLimits, $totalOps, $emptyResult;
17+
global $sqlite3_dbpath, $debugMode;
18+
19+
if (!is_file('kvstorage-mysql.inc')){
20+
print("storage no file");
21+
return $emptyResult;
22+
}
23+
if (!function_exists('mysql_query')){
24+
ptint("no func");
25+
return $emptyResult;
26+
}
27+
28+
include_once('kvstorage-mysql.inc');
29+
$kvstorage=new KVStorageMysql();
30+
$kvstorage->engineName='INNOdb';
31+
$kvstorage->open();
32+
$kvstorage->drop();
33+
$kvstorage->create();
34+
if (!$kvstorage->available){
35+
print("storage noavail");
36+
return $emptyResult;
37+
}
38+
39+
$count = $testsLoopLimits['45_02_kvs_mysql_innodb'];
40+
$time_start = get_microtime();
41+
42+
for ($i = 0; $i < $count; $i++) {
43+
$num = $i / 100.;
44+
$kvstorage->set($i, $num);
45+
$v=$kvstorage->get($i);
46+
$kvstorage->del($i);
47+
}
48+
$kvstorage->close();
49+
$totalOps += $count;
50+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
51+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /