NonLazyUuidConversionBench.php 873 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * This file is part of the ramsey/uuid library
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. *
  8. * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
  9. * @license http://opensource.org/licenses/MIT MIT
  10. */
  11. declare(strict_types=1);
  12. namespace Ramsey\Uuid\Benchmark;
  13. use Ramsey\Uuid\UuidFactory;
  14. use Ramsey\Uuid\UuidInterface;
  15. final class NonLazyUuidConversionBench
  16. {
  17. private const UUID_BYTES = [
  18. "\x1e\x94\x42\x33\x98\x10\x41\x38\x96\x22\x56\xe1\xf9\x0c\x56\xed",
  19. ];
  20. private UuidInterface $uuid;
  21. public function __construct()
  22. {
  23. $factory = new UuidFactory();
  24. $this->uuid = $factory->fromBytes(self::UUID_BYTES[0]);
  25. }
  26. public function benchStringConversionOfUuid(): void
  27. {
  28. $this->uuid->toString();
  29. }
  30. }