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 dfb485e

Browse files
Merge pull request 'Add simple tests of libgd saving various formats' (#18) from issue-17-libgd-empty-images-save into master
Reviewed-on: https://gitea.rusoft.ru/open-source/php-simple-benchmark-script/pulls/18
2 parents f2eef76 + 74498c5 commit dfb485e

File tree

8 files changed

+247
-5
lines changed

8 files changed

+247
-5
lines changed

‎bench.php

Lines changed: 45 additions & 3 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 4, 2025 #
13-
# Version : 1.0.62 #
13+
# Version : 1.0.63-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 #
@@ -20,7 +20,7 @@
2020

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

23-
$scriptVersion = '1.0.62';
23+
$scriptVersion = '1.0.63-dev';
2424

2525
// Special string to flush buffers, nginx for example
2626
$flushStr = '<!-- '.str_repeat("", 8192).' -->';
@@ -138,6 +138,11 @@
138138
if (extension_loaded('gd')) {
139139
@include_once("php-gd-imagick-common.inc");
140140
@include_once("php-gd.inc");
141+
@include_once("mod-gd-empty-gif.inc");
142+
@include_once("mod-gd-empty-png.inc");
143+
@include_once("mod-gd-empty-jpg.inc");
144+
@include_once("mod-gd-empty-webp.inc");
145+
@include_once("mod-gd-empty-avif.inc");
141146
}
142147
if (extension_loaded('imagick')) {
143148
@include_once("php-gd-imagick-common.inc");
@@ -815,6 +820,11 @@ function gethostname() {
815820
'39_07_kvs_sqlite3_generic_file' => 500000,
816821
'39_08_kvs_sqlite3_devshm_file' => 500000,
817822
'39_09_kvs_sqlite3_memory_file' => 500000,
823+
'40_01_gd_save_fill_empty_gif' => 10000,
824+
'40_02_gd_save_fill_empty_png' => 10000,
825+
'40_03_gd_save_fill_empty_jpg' => 10000,
826+
'40_04_gd_save_fill_empty_webp' => 10000,
827+
'40_05_gd_save_fill_empty_avif' => 10000,
818828
);
819829
// Should not be more than X Mb
820830
// Different PHP could use different amount of memory
@@ -882,6 +892,11 @@ function gethostname() {
882892
'39_07_kvs_sqlite3_generic_file' => 4,
883893
'39_08_kvs_sqlite3_devshm_file' => 4,
884894
'39_09_kvs_sqlite3_memory_file' => 4,
895+
'40_01_gd_save_fill_empty_gif' => 4,
896+
'40_02_gd_save_fill_empty_png' => 4,
897+
'40_03_gd_save_fill_empty_jpg' => 4,
898+
'40_04_gd_save_fill_empty_webp' => 4,
899+
'40_05_gd_save_fill_empty_avif' => 4,
885900
);
886901

887902
/** ---------------------------------- Common functions -------------------------------------------- */
@@ -1721,6 +1736,26 @@ function filter_out_name_by_pattern($key)
17211736
$has_eacc = "{$colorYellow}yes{$colorReset}";
17221737
}
17231738
$has_gd = "{$colorYellow}no{$colorReset}";
1739+
$has_gdgif = "{$colorYellow}no{$colorReset}";
1740+
$has_gdpng = "{$colorYellow}no{$colorReset}";
1741+
$has_gdjpg = "{$colorYellow}no{$colorReset}";
1742+
$has_gdwebp = "{$colorYellow}no{$colorReset}";
1743+
$has_gdavif = "{$colorYellow}no{$colorReset}";
1744+
if (function_exists('imagegif')) {
1745+
$has_gdgif = "{$colorGreen}yes{$colorReset}";
1746+
}
1747+
if (function_exists('imagepng')) {
1748+
$has_gdpng = "{$colorGreen}yes{$colorReset}";
1749+
}
1750+
if (function_exists('imagejpeg')) {
1751+
$has_gdjpg = "{$colorGreen}yes{$colorReset}";
1752+
}
1753+
if (function_exists('imagewebp')) {
1754+
$has_gdwebp = "{$colorGreen}yes{$colorReset}";
1755+
}
1756+
if (function_exists('imageavif')) {
1757+
$has_gdavif = "{$colorGreen}yes{$colorReset}";
1758+
}
17241759
if (extension_loaded('gd')) {
17251760
$has_gd = "{$colorGreen}yes{$colorReset}";
17261761
$info = gd_info();
@@ -1808,6 +1843,7 @@ function filter_out_name_by_pattern($key)
18081843
if (!defined('ZLIB_VERSION')) define('ZLIB_VERSION', '-.--');
18091844
if (!defined('MEMCACHE_VERSION')) define('MEMCACHE_VERSION', '-.--');
18101845
if (!defined('REDIS_VERSION')) define('REDIS_VERSION', '-.--');
1846+
if (!defined('SQLITE3_VERSION')) define('SQLITE3_VERSION', '-.--');
18111847
if (!defined('LIBXML_DOTTED_VERSION')) define('LIBXML_DOTTED_VERSION', '-.-.-');
18121848
if (!defined('INTL_ICU_VERSION')) define('INTL_ICU_VERSION', '-.-');
18131849
if (!defined('LIBZSTD_VERSION_STRING')) define('LIBZSTD_VERSION_STRING', '-.-.-');
@@ -1819,7 +1855,8 @@ function print_results_common()
18191855
global $availableFunctions;
18201856
global $line, $padHeader, $cpuInfo, $padInfo, $scriptVersion, $maxTime, $originTimeLimit, $originMemoryLimit, $cryptAlgoName, $memoryLimitMb;
18211857
global $flushStr, $has_apc, $has_pcre, $has_intl, $has_json, $has_simplexml, $has_dom, $has_mbstring, $has_opcache, $has_xcache;
1822-
global $has_gd, $has_imagick, $has_igb, $has_msg, $has_jsond, $has_jsond_as_json;
1858+
global $has_gd, $has_gdgif, $has_gdpng, $has_gdjpg, $has_gdwebp, $has_gdavif;
1859+
global $has_imagick, $has_igb, $has_msg, $has_jsond, $has_jsond_as_json;
18231860
global $has_zlib, $has_uuid, $has_gzip, $has_bz2, $has_lz4, $has_snappy, $has_zstd, $has_brotli;
18241861
global $has_apcu, $has_shmop, $has_memcache, $has_redis, $has_sqlite3, $opcache, $has_eacc, $has_xdebug, $xcache, $apcache, $eaccel, $xdebug, $xdbg_mode, $obd_set, $mbover;
18251862
global $showOnlySystemInfo, $padLabel, $functions, $runOnlySelectedTests, $selectedTests, $totalOps;
@@ -1856,6 +1893,11 @@ function print_results_common()
18561893
. str_pad("intl", $padInfo, '', STR_PAD_LEFT) . " : $has_intl" . ($has_intl == "{$colorGreen}yes{$colorReset}" ? '; icu version: ' . INTL_ICU_VERSION : '')."\n"
18571894
. str_pad("-optional->", $padInfo, '', STR_PAD_LEFT) . "\n"
18581895
. str_pad("gd", $padInfo, '', STR_PAD_LEFT) . " : $has_gd: version: ". GD_VERSION."\n"
1896+
. str_pad("\t- GIF", $padInfo, '', STR_PAD_LEFT) . " : $has_gdgif"."\n"
1897+
. str_pad("\t- PNG", $padInfo, '', STR_PAD_LEFT) . " : $has_gdpng"."\n"
1898+
. str_pad("\t- JPG", $padInfo, '', STR_PAD_LEFT) . " : $has_gdjpg"."\n"
1899+
. str_pad("\t- WEBP", $padInfo, '', STR_PAD_LEFT) . " : $has_gdwebp"."\n"
1900+
. str_pad("\t- AVIF", $padInfo, '', STR_PAD_LEFT) . " : $has_gdavif"."\n"
18591901
. str_pad("imagick", $padInfo, '', STR_PAD_LEFT) . " : $has_imagick: version: ".IMG_VERSION."\n"
18601902
. str_pad("apcu", $padInfo, '', STR_PAD_LEFT) . " : $has_apcu;\n"
18611903
. str_pad("shmop", $padInfo, '', STR_PAD_LEFT) . " : $has_shmop;\n"

‎kvstorage.sqlite3

-15.4 MB
Binary file not shown.

‎mod-gd-empty-avif.inc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* module gd+avif test functions
4+
* Php 5.2+
5+
*/
6+
7+
/** ---------------------------------- Tests functions -------------------------------------------- */
8+
9+
function test_40_05_gd_save_fill_empty_avif()
10+
{
11+
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
12+
13+
if (!function_exists('imageavif')) {
14+
return $emptyResult;
15+
}
16+
if (!function_exists('imagecreatetruecolor')) {
17+
return $emptyResult;
18+
}
19+
if (!function_exists('imagefilledrectangle')) {
20+
return $emptyResult;
21+
}
22+
23+
// Create a new image instance
24+
$im = imagecreatetruecolor(1, 1);
25+
26+
// Make the background white
27+
imagefilledrectangle($im, 0, 0, 1, 1, 0xFFFFFF);
28+
29+
$count = $testsLoopLimits['40_05_gd_save_fill_empty_avif'];
30+
$time_start = get_microtime();
31+
$nillpath='/dev/null';
32+
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
33+
$nillpath='\\.\NUL';
34+
}
35+
for ($i = 0; $i < $count; $i++) {
36+
imageavif($im, $nillpath);
37+
}
38+
$totalOps += $count;
39+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
40+
}

‎mod-gd-empty-gif.inc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* module gd+gif test functions
4+
* Php 5.2+
5+
*/
6+
7+
/** ---------------------------------- Tests functions -------------------------------------------- */
8+
9+
function test_40_01_gd_save_fill_empty_gif()
10+
{
11+
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
12+
13+
if (!function_exists('imagegif')) {
14+
return $emptyResult;
15+
}
16+
if (!function_exists('imagecreatetruecolor')) {
17+
return $emptyResult;
18+
}
19+
if (!function_exists('imagefilledrectangle')) {
20+
return $emptyResult;
21+
}
22+
23+
// Create a new image instance
24+
$im = imagecreatetruecolor(1, 1);
25+
26+
// Make the background white
27+
imagefilledrectangle($im, 0, 0, 1, 1, 0xFFFFFF);
28+
29+
$count = $testsLoopLimits['40_01_gd_save_fill_empty_gif'];
30+
$time_start = get_microtime();
31+
$nillpath='/dev/null';
32+
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
33+
$nillpath='\\.\NUL';
34+
}
35+
for ($i = 0; $i < $count; $i++) {
36+
imagegif($im, $nillpath);
37+
}
38+
$totalOps += $count;
39+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
40+
}

‎mod-gd-empty-jpg.inc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* module gd+jpg test functions
4+
* Php 5.2+
5+
*/
6+
7+
/** ---------------------------------- Tests functions -------------------------------------------- */
8+
9+
function test_40_03_gd_save_fill_empty_jpg()
10+
{
11+
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
12+
13+
if (!function_exists('imagejpeg')) {
14+
return $emptyResult;
15+
}
16+
if (!function_exists('imagecreatetruecolor')) {
17+
return $emptyResult;
18+
}
19+
if (!function_exists('imagefilledrectangle')) {
20+
return $emptyResult;
21+
}
22+
23+
// Create a new image instance
24+
$im = imagecreatetruecolor(1, 1);
25+
26+
// Make the background white
27+
imagefilledrectangle($im, 0, 0, 1, 1, 0xFFFFFF);
28+
29+
$count = $testsLoopLimits['40_03_gd_save_fill_empty_jpg'];
30+
$time_start = get_microtime();
31+
$nillpath='/dev/null';
32+
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
33+
$nillpath='\\.\NUL';
34+
}
35+
for ($i = 0; $i < $count; $i++) {
36+
imagejpeg($im, $nillpath);
37+
}
38+
$totalOps += $count;
39+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
40+
}

‎mod-gd-empty-png.inc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* module gd+png test functions
4+
* Php 5.2+
5+
*/
6+
7+
/** ---------------------------------- Tests functions -------------------------------------------- */
8+
9+
function test_40_02_gd_save_fill_empty_png()
10+
{
11+
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
12+
13+
if (!function_exists('imagepng')) {
14+
return $emptyResult;
15+
}
16+
if (!function_exists('imagecreatetruecolor')) {
17+
return $emptyResult;
18+
}
19+
if (!function_exists('imagefilledrectangle')) {
20+
return $emptyResult;
21+
}
22+
23+
// Create a new image instance
24+
$im = imagecreatetruecolor(1, 1);
25+
26+
// Make the background white
27+
imagefilledrectangle($im, 0, 0, 1, 1, 0xFFFFFF);
28+
29+
$count = $testsLoopLimits['40_02_gd_save_fill_empty_png'];
30+
$time_start = get_microtime();
31+
$nillpath='/dev/null';
32+
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
33+
$nillpath='\\.\NUL';
34+
}
35+
for ($i = 0; $i < $count; $i++) {
36+
imagepng($im, $nillpath);
37+
}
38+
$totalOps += $count;
39+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
40+
}

‎mod-gd-empty-webp.inc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* module gd+webp test functions
4+
* Php 5.2+
5+
*/
6+
7+
/** ---------------------------------- Tests functions -------------------------------------------- */
8+
9+
function test_40_04_gd_save_fill_empty_webp()
10+
{
11+
global $stringTest, $emptyResult, $testsLoopLimits, $totalOps;
12+
13+
if (!function_exists('imagewebp')) {
14+
return $emptyResult;
15+
}
16+
if (!function_exists('imagecreatetruecolor')) {
17+
return $emptyResult;
18+
}
19+
if (!function_exists('imagefilledrectangle')) {
20+
return $emptyResult;
21+
}
22+
23+
// Create a new image instance
24+
$im = imagecreatetruecolor(1, 1);
25+
26+
// Make the background white
27+
imagefilledrectangle($im, 0, 0, 1, 1, 0xFFFFFF);
28+
29+
$count = $testsLoopLimits['40_04_gd_save_fill_empty_webp'];
30+
$time_start = get_microtime();
31+
$nillpath='/dev/null';
32+
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
33+
$nillpath='\\.\NUL';
34+
}
35+
for ($i = 0; $i < $count; $i++) {
36+
imagewebp($im, $nillpath);
37+
}
38+
$totalOps += $count;
39+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
40+
}

‎sqlite3.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
function get_sqlite3_object()
99
{
10-
global $sqlite3_dbpath, $debugMode;
11-
if ($debugMode0) var_dump($sqlite3_dbpath);
10+
global $sqlite3_dbpath=':memory:', $debugMode;
11+
if ($debugMode) var_dump($sqlite3_dbpath);
1212
static $s=null;
1313
if ($s!==null){$s->close(); $s=null;}
1414
if ($s===null)

0 commit comments

Comments
(0)

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