Skip to content

Commit e3335a6

Browse files
committed
:octocat: decrease versions to benchmark
1 parent f02b94f commit e3335a6

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

benchmark/BenchmarkAbstract.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,13 @@ public function assignParams(array $params):void{
122122
}
123123

124124
public function versionProvider():Generator{
125-
for($v = 1; $v <= 40; $v++){
126-
$version = new Version($v);
127-
128-
yield (string)$version => ['version' => $version];
125+
// run all versions between 1 and 10 as they're the most commonly used
126+
for($v = 1; $v <= 10; $v++){
127+
yield (string)$v => ['version' => new Version($v)];
128+
}
129+
// 15-40 in steps of 5
130+
for($v = 15; $v <= 40; $v += 5){
131+
yield (string)$v => ['version' => new Version($v)];
129132
}
130133
}
131134

benchmark/MaskPatternBenchmark.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111

1212
namespace chillerlan\QRCodeBenchmark;
1313

14-
use chillerlan\QRCode\Common\{MaskPattern, Mode};
14+
use chillerlan\QRCode\Common\{MaskPattern, Mode, Version};
1515
use chillerlan\QRCode\Data\Byte;
1616
use PhpBench\Attributes\{BeforeMethods, Subject};
17+
use Generator;
18+
use function range;
1719

1820
/**
1921
* Tests the performance of the mask pattern penalty testing
@@ -22,6 +24,12 @@ final class MaskPatternBenchmark extends BenchmarkAbstract{
2224

2325
protected const DATAMODES = [Mode::BYTE => Byte::class];
2426

27+
public function versionProvider():Generator{
28+
for($v = 1; $v <= 40; $v++){
29+
yield (string)$v => ['version' => new Version($v)];
30+
}
31+
}
32+
2533
public function initOptions():void{
2634

2735
$options = [

benchmark/OutputBenchmark.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
namespace chillerlan\QRCodeBenchmark;
1313

14-
use chillerlan\QRCode\Common\{EccLevel, Mode};
14+
use chillerlan\QRCode\Common\Mode;
1515
use chillerlan\QRCode\Data\Byte;
1616
use chillerlan\QRCode\Output\{
17-
QREps, QRFpdf, QRGdImageJPEG, QRGdImagePNG, QRGdImageWEBP, QRImagick, QRMarkupSVG, QRStringJSON
17+
QREps, QRFpdf, QRGdImageAVIF, QRGdImageJPEG, QRGdImagePNG, QRGdImageWEBP, QRImagick, QRMarkupSVG, QRStringJSON
1818
};
1919
use PhpBench\Attributes\{BeforeMethods, Subject};
2020

@@ -24,8 +24,7 @@
2424
#[BeforeMethods(['assignParams', 'generateTestData', 'initOptions', 'initMatrix'])]
2525
final class OutputBenchmark extends BenchmarkAbstract{
2626

27-
protected const ECC_LEVELS = [EccLevel::H];
28-
protected const DATAMODES = [Mode::BYTE => Byte::class];
27+
protected const DATAMODES = [Mode::BYTE => Byte::class];
2928

3029
public function initOptions():void{
3130

@@ -54,10 +53,10 @@ public function QRFpdf():void{
5453
/**
5554
* for some reason imageavif() is extremely slow, ~50x slower than imagepng()
5655
*/
57-
# #[Subject]
58-
# public function QRGdImageAVIF():void{
59-
# (new QRGdImageAVIF($this->options, $this->matrix))->dump();
60-
# }
56+
#[Subject]
57+
public function QRGdImageAVIF():void{
58+
(new QRGdImageAVIF($this->options, $this->matrix))->dump();
59+
}
6160

6261
#[Subject]
6362
public function QRGdImageJPEG():void{

benchmark/generate-markdown.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use function file_exists;
1919
use function file_get_contents;
2020
use function file_put_contents;
21+
use function htmlspecialchars;
2122
use function implode;
2223
use function is_bool;
2324
use function is_dir;
@@ -46,7 +47,7 @@
4647
$markdown['Readme'][] = '|------|-------|';
4748
$markdown['Readme'][] = sprintf('| date | %s %s |', $suite['date'], $suite['time']);
4849
$markdown['Readme'][] = sprintf('| environment | %s %s, %s |', $env['uname_os'], $env['uname_version'], $env['uname_machine']);
49-
$markdown['Readme'][] = sprintf('| tag | %s |', $suite['tag']);
50+
$markdown['Readme'][] = sprintf('| tag | %s |', htmlspecialchars($suite['tag']));
5051

5152

5253
foreach(['php_version', 'php_ini', 'php_extensions', 'php_xdebug', 'opcache_extension_loaded', 'opcache_enabled'] as $field){

0 commit comments

Comments
 (0)