diff --git a/benchmark/BenchmarkAbstract.php b/benchmark/BenchmarkAbstract.php index 5cfebdb6d..3ee625a0b 100644 --- a/benchmark/BenchmarkAbstract.php +++ b/benchmark/BenchmarkAbstract.php @@ -122,10 +122,13 @@ abstract class BenchmarkAbstract{ } public function versionProvider():Generator{ - for($v = 1; $v <= 40; $v++){ - $version = new Version($v); - - yield (string)$version => ['version' => $version]; + // run all versions between 1 and 10 as they're the most commonly used + for($v = 1; $v <= 10; $v++){ + yield (string)$v => ['version' => new Version($v)]; + } + // 15-40 in steps of 5 + for($v = 15; $v <= 40; $v += 5){ + yield (string)$v => ['version' => new Version($v)]; } } diff --git a/benchmark/MaskPatternBenchmark.php b/benchmark/MaskPatternBenchmark.php index 752fb395f..2af5645c8 100644 --- a/benchmark/MaskPatternBenchmark.php +++ b/benchmark/MaskPatternBenchmark.php @@ -11,9 +11,11 @@ declare(strict_types=1); namespace chillerlan\QRCodeBenchmark; -use chillerlan\QRCode\Common\{MaskPattern, Mode}; +use chillerlan\QRCode\Common\{MaskPattern, Mode, Version}; use chillerlan\QRCode\Data\Byte; use PhpBench\Attributes\{BeforeMethods, Subject}; +use Generator; +use function range; /** * Tests the performance of the mask pattern penalty testing @@ -22,6 +24,12 @@ final class MaskPatternBenchmark extends BenchmarkAbstract{ protected const DATAMODES = [Mode::BYTE => Byte::class]; + public function versionProvider():Generator{ + for($v = 1; $v <= 40; $v++){ + yield (string)$v => ['version' => new Version($v)]; + } + } + public function initOptions():void{ $options = [ diff --git a/benchmark/OutputBenchmark.php b/benchmark/OutputBenchmark.php index 3b6c883b5..a895a7097 100644 --- a/benchmark/OutputBenchmark.php +++ b/benchmark/OutputBenchmark.php @@ -11,10 +11,10 @@ declare(strict_types=1); namespace chillerlan\QRCodeBenchmark; -use chillerlan\QRCode\Common\{EccLevel, Mode}; +use chillerlan\QRCode\Common\Mode; use chillerlan\QRCode\Data\Byte; use chillerlan\QRCode\Output\{ - QREps, QRFpdf, QRGdImageJPEG, QRGdImagePNG, QRGdImageWEBP, QRImagick, QRMarkupSVG, QRStringJSON + QREps, QRFpdf, QRGdImageAVIF, QRGdImageJPEG, QRGdImagePNG, QRGdImageWEBP, QRImagick, QRMarkupSVG, QRStringJSON }; use PhpBench\Attributes\{BeforeMethods, Subject}; @@ -24,8 +24,7 @@ use PhpBench\Attributes\{BeforeMethods, Subject}; #[BeforeMethods(['assignParams', 'generateTestData', 'initOptions', 'initMatrix'])] final class OutputBenchmark extends BenchmarkAbstract{ - protected const ECC_LEVELS = [EccLevel::H]; - protected const DATAMODES = [Mode::BYTE => Byte::class]; + protected const DATAMODES = [Mode::BYTE => Byte::class]; public function initOptions():void{ @@ -54,10 +53,10 @@ final class OutputBenchmark extends BenchmarkAbstract{ /** * for some reason imageavif() is extremely slow, ~50x slower than imagepng() */ -# #[Subject] -# public function QRGdImageAVIF():void{ -# (new QRGdImageAVIF($this->options, $this->matrix))->dump(); -# } + #[Subject] + public function QRGdImageAVIF():void{ + (new QRGdImageAVIF($this->options, $this->matrix))->dump(); + } #[Subject] public function QRGdImageJPEG():void{ diff --git a/benchmark/generate-markdown.php b/benchmark/generate-markdown.php index 479cb0394..843e7b494 100644 --- a/benchmark/generate-markdown.php +++ b/benchmark/generate-markdown.php @@ -18,6 +18,7 @@ use function array_keys; use function file_exists; use function file_get_contents; use function file_put_contents; +use function htmlspecialchars; use function implode; use function is_bool; use function is_dir; @@ -46,7 +47,7 @@ $markdown['Readme'][] = '| Name | Value |'; $markdown['Readme'][] = '|------|-------|'; $markdown['Readme'][] = sprintf('| date | %s %s |', $suite['date'], $suite['time']); $markdown['Readme'][] = sprintf('| environment | %s %s, %s |', $env['uname_os'], $env['uname_version'], $env['uname_machine']); -$markdown['Readme'][] = sprintf('| tag | %s |', $suite['tag']); +$markdown['Readme'][] = sprintf('| tag | %s |', htmlspecialchars($suite['tag'])); foreach(['php_version', 'php_ini', 'php_extensions', 'php_xdebug', 'opcache_extension_loaded', 'opcache_enabled'] as $field){