QRCodeBenchmark.php 942 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Class QRCodeBenchmark
  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\Output\QRStringJSON;
  13. use chillerlan\QRCode\QRCode;
  14. use PhpBench\Attributes\{BeforeMethods, Subject};
  15. /**
  16. * Tests the overall performance of the QRCode class
  17. */
  18. final class QRCodeBenchmark extends BenchmarkAbstract{
  19. public function initOptions():void{
  20. $options = [
  21. 'outputInterface' => QRStringJSON::class,
  22. 'version' => $this->version->getVersionNumber(),
  23. 'eccLevel' => $this->eccLevel->getLevel(),
  24. ];
  25. $this->initQROptions($options);
  26. }
  27. #[Subject]
  28. #[BeforeMethods(['assignParams', 'generateTestData', 'initOptions'])]
  29. public function render():void{
  30. (new QRCode($this->options))->addSegment(new $this->modeFQCN($this->testData))->render();
  31. }
  32. }