MaskPatternBenchmark.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. /**
  17. * Tests the performance of the mask pattern penalty testing
  18. */
  19. final class MaskPatternBenchmark extends BenchmarkAbstract{
  20. protected const DATAMODES = [Mode::BYTE => Byte::class];
  21. public function versionProvider():Generator{
  22. for($v = 1; $v <= 40; $v++){
  23. yield (string)$v => ['version' => new Version($v)];
  24. }
  25. }
  26. public function initOptions():void{
  27. $options = [
  28. 'version' => $this->version->getVersionNumber(),
  29. 'eccLevel' => $this->eccLevel->getLevel(),
  30. ];
  31. $this->initQROptions($options);
  32. }
  33. #[Subject]
  34. #[BeforeMethods(['assignParams', 'generateTestData', 'initOptions', 'initMatrix'])]
  35. public function getBestPattern():void{
  36. MaskPattern::getBestPattern($this->matrix);
  37. }
  38. }