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 e76e957

Browse files
Версия 1.0.57 - тесты gd + imagick
1 parent 693e301 commit e76e957

File tree

7 files changed

+204
-12
lines changed

7 files changed

+204
-12
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+
@ 2023年09月22日, v1.0.57
4+
5+
* Добавлены тесты gd & imagick - ктобыстрее рисует простой qrcode
6+
37
@ 2023年09月14日, v1.0.56
48

59
* Добавлены тесты методов сжатия: zlib, bz2, lz4, zstd, brotli

‎README.en.md‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ Required modules for full php testing:
1212
- dom
1313
- simplexml
1414
- intl
15+
- optional:
16+
- gd
17+
- imagick
18+
- zlib
19+
- bz2
20+
- brotli
21+
- zstd
22+
- igbinary
23+
- msgpack
1524

1625
Usually they are already installed or "compiled" in php.
1726

@@ -30,7 +39,7 @@ How to check it:
3039

3140
### 0. Files
3241

33-
You need to put these files in one directory: `bench.php`, `common.inc`, `php5.inc`, `php7.inc`, `igbinary.inc`, `msgpack.inc`, `compression.inc`, `test.xml`.
42+
You need to put these files in one directory: `bench.php`, `common.inc`, `php5.inc`, `php7.inc`, `igbinary.inc`, `msgpack.inc`, `compression.inc`, `php-gd-imagick-common.inc`, `php-gd.inc`, `php-imagick.inc`, `test.xml`.
3443

3544
### 1. Through the console
3645

@@ -137,7 +146,7 @@ CPU :
137146
cores : 4
138147
available : 4
139148
MHz : 3600 MHz
140-
Benchmark version : 1.0.56
149+
Benchmark version : 1.0.57
141150
PHP version : 7.4.29-SergeyD/6.1
142151
PHP time limit : 0 sec
143152
Setup time limit : 600 sec
@@ -152,6 +161,9 @@ Crypt hash algo : MD5
152161
simplexml : yes; libxml version: 2.9.4
153162
dom : yes
154163
intl : yes; icu version: 66.1
164+
-optional->
165+
gd : yes: version: 2.2.5
166+
imagick : yes: version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
155167
-alternative->
156168
igbinary : yes
157169
msgpack : yes
@@ -220,6 +232,8 @@ TEST NAME : SECONDS | OP/SEC | OP/SEC/MHz |
220232
31_intl_message_format : 4.236 sec | 47.22 kOp/s | 12.46 Ops/MHz | 4 Mb
221233
32_intl_calendar : 0.844 sec | 355.34 kOp/s | 93.79 Ops/MHz | 4 Mb
222234
33_phpinfo_generate : 1.440 sec | 6.95 kOp/s | 1.83 Ops/MHz | 4 Mb
235+
34_gd_qrcode : 0.923 sec | 1.08 kOp/s | 0.30 Ops/MHz | 4 Mb
236+
35_imagick_qrcode : 2.839 sec | 352.18 Op/s | 0.10 Ops/MHz | 4 Mb
223237
36_brotli_compress : 5.012 sec | 199.50 kOp/s | 51.47 Ops/MHz | 3 Mb
224238
36_bzip2_compress : 22.065 sec | 22.66 kOp/s | 5.85 Ops/MHz | 3 Mb
225239
36_gzip_compress : 52.977 sec | 94.38 kOp/s | 24.35 Ops/MHz | 3 Mb

‎README.md‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
- dom
1313
- simplexml
1414
- intl
15+
- optional:
16+
- gd
17+
- imagick
18+
- brotli
19+
- zlib
20+
- bz2
21+
- zstd
22+
- igbinary
23+
- msgpack
1524

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

@@ -30,7 +39,7 @@
3039

3140
### 0. Файлы
3241

33-
Нужно положить в один каталог файлы: `bench.php`, `common.inc`, `php5.inc`, `php7.inc`, `igbinary.inc`, `msgpack.inc`, `compression.inc`, `test.xml`.
42+
Нужно положить в один каталог файлы: `bench.php`, `common.inc`, `php5.inc`, `php7.inc`, `igbinary.inc`, `msgpack.inc`, `compression.inc`, `php-gd-imagick-common.inc`, `php-gd.inc`, `php-imagick.inc`, `test.xml`.
3443

3544
### 1. Через консоль
3645

@@ -138,7 +147,7 @@ CPU :
138147
cores : 4
139148
available : 4
140149
MHz : 3600 MHz
141-
Benchmark version : 1.0.56
150+
Benchmark version : 1.0.57
142151
PHP version : 7.4.29-SergeyD/6.1
143152
PHP time limit : 0 sec
144153
Setup time limit : 600 sec
@@ -153,6 +162,9 @@ Crypt hash algo : MD5
153162
simplexml : yes; libxml version: 2.9.4
154163
dom : yes
155164
intl : yes; icu version: 66.1
165+
-optional->
166+
gd : yes: version: 2.2.5
167+
imagick : yes: version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
156168
-alternative->
157169
igbinary : yes
158170
msgpack : yes
@@ -221,6 +233,8 @@ TEST NAME : SECONDS | OP/SEC | OP/SEC/MHz |
221233
31_intl_message_format : 4.236 sec | 47.22 kOp/s | 12.46 Ops/MHz | 4 Mb
222234
32_intl_calendar : 0.844 sec | 355.34 kOp/s | 93.79 Ops/MHz | 4 Mb
223235
33_phpinfo_generate : 1.440 sec | 6.95 kOp/s | 1.83 Ops/MHz | 4 Mb
236+
34_gd_qrcode : 0.923 sec | 1.08 kOp/s | 0.30 Ops/MHz | 4 Mb
237+
35_imagick_qrcode : 2.839 sec | 352.18 Op/s | 0.10 Ops/MHz | 4 Mb
224238
36_brotli_compress : 5.012 sec | 199.50 kOp/s | 51.47 Ops/MHz | 3 Mb
225239
36_bzip2_compress : 22.065 sec | 22.66 kOp/s | 5.85 Ops/MHz | 3 Mb
226240
36_gzip_compress : 52.977 sec | 94.38 kOp/s | 24.35 Ops/MHz | 3 Mb

‎bench.php‎

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
# Company : Code24 BV, The Netherlands #
1010
# Author : Sergey Dryabzhinsky #
1111
# Company : Rusoft Ltd, Russia #
12-
# Date : Jun 05, 2023 #
13-
# Version : 1.0.56 #
12+
# Date : Sep 22, 2023 #
13+
# Version : 1.0.57 #
1414
# License : Creative Commons CC-BY license #
1515
# Website : https://github.com/rusoft/php-simple-benchmark-script #
1616
# Website : https://git.rusoft.ru/open-source/php-simple-benchmark-script #
1717
# #
1818
################################################################################
1919
*/
2020

21-
$scriptVersion = '1.0.56';
21+
$scriptVersion = '1.0.57';
2222

2323
// Special string to flush buffers, nginx for example
2424
$flushStr = '<!-- '.str_repeat("", 8192).' -->';
@@ -88,6 +88,14 @@
8888
if (extension_loaded('brotli')) {
8989
@include_once("compression.inc");
9090
}
91+
if (extension_loaded('gd')) {
92+
@include_once("php-gd-imagick-common.inc");
93+
@include_once("php-gd.inc");
94+
}
95+
if (extension_loaded('imagick')) {
96+
@include_once("php-gd-imagick-common.inc");
97+
@include_once("php-imagick.inc");
98+
}
9199

92100
$originMemoryLimit = @ini_get('memory_limit');
93101
$originTimeLimit = @ini_get('max_execution_time');
@@ -705,8 +713,8 @@ function gethostname() {
705713
'31_intl_message_format' => 200000,
706714
'32_intl_calendar' => 300000,
707715
'33_phpinfo_generate' => 10000,
708-
'34_gd_qrcode' => 700,
709-
'35_imagick_qrcode' => 200,
716+
'34_gd_qrcode' => 1000,
717+
'35_imagick_qrcode' => 1000,
710718
'36_zlib_compress' => 5000000,
711719
'36_gzip_compress' => 5000000,
712720
'36_bzip2_compress' => 500000,
@@ -1550,10 +1558,18 @@ function format_result_test($diffSeconds, $opCount, $memory = 0)
15501558
$has_gd = "{$colorYellow}no{$colorReset}";
15511559
if (extension_loaded('gd')) {
15521560
$has_gd = "{$colorGreen}yes{$colorReset}";
1561+
$info = gd_info();
1562+
define("GD_VERSION",$info["GD Version"]);
1563+
} else {
1564+
define("GD_VERSION","-.-.-");
15531565
}
15541566
$has_imagick = "{$colorYellow}no{$colorReset}";
15551567
if (extension_loaded('imagick')) {
15561568
$has_imagick = "{$colorGreen}yes{$colorReset}";
1569+
$imv = Imagick::getVersion();
1570+
define("IMG_VERSION", $imv["versionString"]);
1571+
} else {
1572+
define("IMG_VERSION", "-.-.-");
15571573
}
15581574
$has_xdebug = "{$colorGreen}no{$colorReset}";
15591575
if (extension_loaded('xdebug')) {
@@ -1581,8 +1597,12 @@ function format_result_test($diffSeconds, $opCount, $memory = 0)
15811597
$has_intl = "{$colorGreen}yes{$colorReset}";
15821598
}
15831599
$has_zlib = "{$colorYellow}no{$colorReset}";
1600+
$has_gzip = "{$colorYellow}no{$colorReset}";
15841601
if (extension_loaded('zlib')) {
15851602
$has_zlib = "{$colorGreen}yes{$colorReset}";
1603+
if(function_exists('gzencode')) {
1604+
$has_gzip = "{$colorGreen}yes{$colorReset}";
1605+
}
15861606
}
15871607
$has_bz2 = "{$colorYellow}no{$colorReset}";
15881608
if (extension_loaded('bz2')) {
@@ -1621,7 +1641,7 @@ function print_results_common()
16211641
global $line, $padHeader, $cpuInfo, $padInfo, $scriptVersion, $maxTime, $originTimeLimit, $originMemoryLimit, $cryptAlgoName, $memoryLimitMb;
16221642
global $flushStr, $has_apc, $has_pcre, $has_intl, $has_json, $has_simplexml, $has_dom, $has_mbstring, $has_opcache, $has_xcache;
16231643
global $has_gd, $has_imagick, $has_igb, $has_msg, $has_jsond, $has_jsond_as_json;
1624-
global $has_zlib, $has_bz2, $has_lz4, $has_zstd, $has_brotli;
1644+
global $has_zlib, $has_gzip, $has_bz2, $has_lz4, $has_zstd, $has_brotli;
16251645
global $opcache, $has_eacc, $has_xdebug, $xcache, $apcache, $eaccel, $xdebug, $xdbg_mode, $obd_set, $mbover;
16261646
global $showOnlySystemInfo, $padLabel, $functions, $runOnlySelectedTests, $selectedTests, $totalOps;
16271647
global $colorGreen, $colorReset, $colorRed;
@@ -1656,15 +1676,16 @@ function print_results_common()
16561676
. str_pad("dom", $padInfo, '', STR_PAD_LEFT) . " : $has_dom\n"
16571677
. str_pad("intl", $padInfo, '', STR_PAD_LEFT) . " : $has_intl" . ($has_intl == "{$colorGreen}yes{$colorReset}" ? '; icu version: ' . INTL_ICU_VERSION : '')."\n"
16581678
. str_pad("-optional->", $padInfo, '', STR_PAD_LEFT) . "\n"
1659-
. str_pad("gd", $padInfo, '', STR_PAD_LEFT) . " : $has_gd\n"
1660-
. str_pad("imagick", $padInfo, '', STR_PAD_LEFT) . " : $has_imagick\n"
1679+
. str_pad("gd", $padInfo, '', STR_PAD_LEFT) . " : $has_gd: version: ". GD_VERSION."\n"
1680+
. str_pad("imagick", $padInfo, '', STR_PAD_LEFT) . " : $has_imagick: version: ".IMG_VERSION."\n"
16611681
. str_pad("-alternative->", $padInfo, '', STR_PAD_LEFT) . "\n"
16621682
. str_pad("igbinary", $padInfo, '', STR_PAD_LEFT) . " : $has_igb\n"
16631683
. str_pad("msgpack", $padInfo, '', STR_PAD_LEFT) . " : $has_msg\n"
16641684
. str_pad("jsond", $padInfo, '', STR_PAD_LEFT) . " : $has_jsond\n"
16651685
. str_pad("jsond as json >>", $padInfo, '', STR_PAD_LEFT) . " : $has_jsond_as_json\n"
16661686
. str_pad("-compression->", $padInfo, '', STR_PAD_LEFT) . "\n"
16671687
. str_pad("zlib", $padInfo, '', STR_PAD_LEFT) . " : $has_zlib\n"
1688+
. str_pad("gzip", $padInfo, '', STR_PAD_LEFT) . " : $has_gzip\n"
16681689
. str_pad("bz2", $padInfo, '', STR_PAD_LEFT) . " : $has_bz2\n"
16691690
. str_pad("lz4", $padInfo, '', STR_PAD_LEFT) . " : $has_lz4\n"
16701691
. str_pad("zstd", $padInfo, '', STR_PAD_LEFT) . " : $has_zstd\n"

‎php-gd-imagick-common.inc‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Tests for Imagick
4+
*/
5+
6+
$qr = // The actual QR code
7+
"1111111000011010001111111".
8+
"1000001001100010001000001".
9+
"1011101000001000101011101".
10+
"1011101010001100101011101".
11+
"1011101011000100101011101".
12+
"1000001000011110001000001".
13+
"1111111010101010101111111".
14+
"0000000000110011000000000".
15+
"1100011101010111100011000".
16+
"1010000111001001000111110".
17+
"0011111000100111101001011".
18+
"0000000101001010111101001".
19+
"0100111001011011101000001".
20+
"1101000110000101100100010".
21+
"1010111010011111001111011".
22+
"1010100001110011010010101".
23+
"1010111111111111111110100".
24+
"0000000011001001100010100".
25+
"1111111011010010101011001".
26+
"1000001010110011100010011".
27+
"1011101000011111111111100".
28+
"1011101001111111011101011".
29+
"1011101000100110100100101".
30+
"1000001010100010100110001".
31+
"1111111011101000100001001";

‎php-gd.inc‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Tests for GD
4+
*/
5+
6+
function test_34_gd_qrcode()
7+
{
8+
global $testsLoopLimits, $totalOps, $qr;
9+
10+
$size = 25; // Dimension in dots
11+
$dot = 9; // Pixels per dot
12+
13+
$count = $testsLoopLimits['34_gd_qrcode'];
14+
$time_start = get_microtime();
15+
16+
for ($c=0; $c<$count; $c++) {
17+
18+
$img = imagecreatetruecolor($size * $dot, $size * $dot);
19+
20+
// Enable alpha blending
21+
imagealphablending($img, true);
22+
imagesavealpha($img, true);
23+
24+
// Allocate colors
25+
$back = imagecolorallocatealpha($img, 0, 0, 0, 127);
26+
$dots = imagecolorallocatealpha($img, 0, 64, 127, 64);
27+
28+
// Fill the image with background/transparency
29+
imagefill($img, 0, 0, $back);
30+
31+
// Loop over all dots and draw them:
32+
for ($y = 0, $i = 0; $y < $size; $y++) {
33+
for ($x = 0; $x < $size; $x++, $i++) {
34+
if ($qr[$i] == '1') { // Draw a dot?
35+
// Draw rectangles
36+
imagefilledrectangle($img, $x * $dot, $y * $dot, ($x + 1) * $dot - 1, ($y + 1) * $dot - 1, $dots);
37+
}
38+
}
39+
}
40+
41+
// Save the result
42+
// imagejpeg($img, "test-gd.jpg", 75);
43+
imagejpeg($img, "/dev/null", 75);
44+
45+
imagedestroy($img);
46+
47+
// echo $i . '.';
48+
49+
}
50+
51+
$totalOps += $count;
52+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
53+
}

‎php-imagick.inc‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Tests for Imagick
4+
*/
5+
6+
function test_35_imagick_qrcode()
7+
{
8+
global $testsLoopLimits, $totalOps, $qr;
9+
10+
$size = 25; // Dimension in dots
11+
$dot = 9; // Pixels per dot
12+
$imgW = $imgH = $size;
13+
14+
$count = $testsLoopLimits['35_imagick_qrcode'];
15+
$time_start = get_microtime();
16+
17+
$pixelPerPoint = 9;
18+
$outerFrame = 1;
19+
$q = 75;
20+
21+
$col[0] = new ImagickPixel("white");
22+
$col[1] = new ImagickPixel("black");
23+
24+
for ($c=0; $c<$count; $c++) {
25+
26+
$image = new Imagick();
27+
$image->newImage($imgW, $imgH, $col[0]);
28+
29+
$image->setCompressionQuality($q);
30+
$image->setImageFormat('jpeg');
31+
32+
$draw = new ImagickDraw();
33+
$draw->setFillColor($col[1]);
34+
35+
// Loop over all dots and draw them:
36+
for ($y = 0, $i = 0; $y < $size; $y++) {
37+
for ($x = 0; $x < $size; $x++, $i++) {
38+
if ($qr[$i] == '1') { // Draw a dot?
39+
$draw->point($x,$y);
40+
}
41+
}
42+
}
43+
44+
$image->drawImage($draw);
45+
$image->borderImage($col[0],$outerFrame,$outerFrame);
46+
$image->scaleImage( $imgW * $pixelPerPoint, 0 );
47+
48+
// Save the result
49+
// $image->writeImages("test-im.jpg",true);
50+
$image->writeImages("/dev/null",true);
51+
}
52+
53+
$totalOps += $count;
54+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
55+
}

0 commit comments

Comments
(0)

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