MaskPatternBenchmark.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Class MaskPatternBenchmark
  4. *
  5. * @created 23.04.2024
  6. * @author smiley <smiley@chillerlan.net>
  7. * @copyright 2024 smiley
  8. * @license MIT
  9. */
  10. declare(strict_types=1);
  11. namespace chillerlan\QRCodeBenchmark;
  12. use chillerlan\QRCode\Common\{MaskPattern, Mode, Version};
  13. use chillerlan\QRCode\Data\Byte;
  14. use PhpBench\Attributes\{BeforeMethods, Subject};
  15. use Generator;
  16. use function range;
  17. /**
  18. * Tests the performance of the mask pattern penalty testing
  19. */
  20. final class MaskPatternBenchmark extends BenchmarkAbstract{
  21. protected const DATAMODES = [Mode::BYTE => Byte::class];
  22. public function versionProvider():Generator{
  23. for($v = 1; $v <= 40; $v++){
  24. yield (string)$v => ['version' => new Version($v)];
  25. }
  26. }
  27. public function initOptions():void{
  28. $options = [
  29. 'version' => $this->version->getVersionNumber(),
  30. 'eccLevel' => $this->eccLevel->getLevel(),
  31. ];
  32. $this->initQROptions($options);
  33. }
  34. #[Subject]
  35. #[BeforeMethods(['assignParams', 'generateTestData', 'initOptions', 'initMatrix'])]
  36. public function getBestPattern():void{
  37. MaskPattern::getBestPattern($this->matrix);
  38. }
  39. }