Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.