Skip to content

Instantly share code, notes, and snippets.

@mhujer
Created April 1, 2017 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhujer/e68ec150150b5a2bb1745dd82a008b6c to your computer and use it in GitHub Desktop.
Save mhujer/e68ec150150b5a2bb1745dd82a008b6c to your computer and use it in GitHub Desktop.
ramsey/uuid serialization/deserialization benchmark
<?php
declare(strict_types = 1);
use Ramsey\Uuid\Uuid;
require_once __DIR__ . '/../vendor/autoload.php';
$data = require __DIR__ . '/dataset.php';
foreach ($data as $uuidString) {
$uuid = Uuid::fromString($uuidString);
if ($uuidString !== $uuid->toString()) {
die($uuidString . ' vs ' . $uuid->toString());
}
}
<?php
declare(strict_types = 1);
use Ramsey\Uuid\Uuid;
require_once __DIR__ . '/../vendor/autoload.php';
$uuids = [];
for ($i = 0; $i < 200000; $i++) {
$uuids[] = Uuid::uuid4()->toString();
}
file_put_contents(
__DIR__ . '/dataset.php',
'<?php return ' . var_export($uuids, true) . ';'
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment