Skip to content

Instantly share code, notes, and snippets.

@lyrixx lyrixx/.gitignore
Last active Nov 29, 2019

Embed
What would you like to do?
UUID generation in PHP
/vendor/

We have been using UUID for years and different ways to generate UUID exist.

I prefer the PECL extension over the ramsey/uuid because it’s simpler and more straightforward. Few weeks ago, with Nicolas Grekas we had the idea to port the PECL to plain PHP as a Symfony Polyfill. Then, we wanted to blog about FFI, a new PHP 7.4 feature. With Baptiste Leduc, we bound the libuuid to PHP.

So now, there are many ways to generate UUID in PHP, at least 4. Let's compare them:

I created a benchmark to see how theses implementations compare:

UUID V1 (time based)

+----------------------+---------+-------+
| subject              | mean    | diff  |
+----------------------+---------+-------+
| benchPecl            | 0.637μs | 1.00x |
| benchSymfonyPolyfill | 1.736μs | 2.72x |
| benchJoliCodeFFI     | 1.349μs | 2.12x |
| benchRamsey          | 4.295μs | 6.74x |
+----------------------+---------+-------+

UUID V4 (random values)

+----------------------+---------+-------+
| subject              | mean    | diff  |
+----------------------+---------+-------+
| benchPecl            | 4.546μs | 2.87x |
| benchSymfonyPolyfill | 1.583μs | 1.00x |
| benchJoliCodeFFI     | 5.416μs | 3.42x |
| benchRamsey          | 2.103μs | 1.33x |
+----------------------+---------+-------+

How to explain these numbers?

Requirements: Pseudo-Random values

UUID are composed in part - or totally - by pseudo-random data. Generating random data is something really hard for a computer and slow by design. You can read more on wikipedia about this topic.

For the V1

V1 is time based. It means there are not so much random data. But each UUID must be unique, so an internal counter is required.

  • The PECL is the fastest here because it uses some features of the kernel to get incremental data,
  • The FFI binding is slower because there is a significant overhead with FFI for things that are really fast in the underlying library. This overhead comes from the conversion type between PHP and the underlying library,
  • The Polyfill is slower because it must deal with the counter manually,
  • The Rasmey implementation is the slowest because the way it deals with counter could be improved.

For the V4

V4 is full of random data. It means it is really expensive for the CPU to generate one compared to a V1.

  • The Polyfill is the fastest because it asks for a big amount of random data only once. Then it uses it to generate the UUID,
  • The Rasmey implementation is also very fast for the same reason,
  • The PECL is much slower due to the underlying library (libuuid) asking many pieces of random data (remember it's very slow by design) and then it assembles them,
  • The FFI binding is the slowest since it relies on the same libuuid library, and it adds the FFI overhead.

Conclusion

Now you now know everything about uuid, so… just make the right choice. ;)

Keep in mind that the FFI binding works only with PHP 7.4+, so it’s likely unusable for many projects (for now).

ramsey/uuid is an UUID component that leverage many uuid generator (it can use the PECL internally). It could be interesting to use the polyfill in the ramsey/uuid implementation.

And since the polyfill is the same thing than the PECL extension, the final choice is about the API:

something simple: the PECL (or the polyfill if you can’t install an extension), something more feature-rich: the ramsey/uuid component, something hype: the FFI binding

Now you know everything about the ways to generate UUID in PHP, just use the right one for you.

{
"name": "lyrixx/uuid-bench",
"description": "Some bench for UUID",
"type": "project",
"license": "MIT",
"authors": [
{
"name": "Grégoire Pineau",
"email": "lyrixx@lyrixx.info"
}
],
"repositories": [
{"type": "vcs", "url": "https://github.com/lyrixx/polyfill"}
],
"require": {
"ext-uuid": "*",
"jolicode/ffi-uuid": "^1.0.0",
"phpbench/phpbench": "^0.16.10",
"ramsey/uuid": "^3.8",
"symfony/polyfill": "^1.13"
},
"config": {
"sort-packages": true
}
}
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "f46612db6bedefda2336fcb727d2f083",
"packages": [
{
"name": "beberlei/assert",
"version": "v3.2.6",
"source": {
"type": "git",
"url": "https://github.com/beberlei/assert.git",
"reference": "99508be011753690fe108ded450f5caaae180cfa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/beberlei/assert/zipball/99508be011753690fe108ded450f5caaae180cfa",
"reference": "99508be011753690fe108ded450f5caaae180cfa",
"shasum": ""
},
"require": {
"ext-ctype": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"php": "^7"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "*",
"phpstan/phpstan-shim": "*",
"phpunit/phpunit": ">=6.0.0 <8"
},
"suggest": {
"ext-intl": "Needed to allow Assertion::count(), Assertion::isCountable(), Assertion::minCount(), and Assertion::maxCount() to operate on ResourceBundles"
},
"type": "library",
"autoload": {
"psr-4": {
"Assert\\": "lib/Assert"
},
"files": [
"lib/Assert/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de",
"role": "Lead Developer"
},
{
"name": "Richard Quadling",
"email": "rquadling@gmail.com",
"role": "Collaborator"
}
],
"description": "Thin assertion library for input validation in business models.",
"keywords": [
"assert",
"assertion",
"validation"
],
"time": "2019-10-10T10:33:57+00:00"
},
{
"name": "doctrine/annotations",
"version": "v1.8.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/904dca4eb10715b92569fbcd79e201d5c349b6bc",
"reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc",
"shasum": ""
},
"require": {
"doctrine/lexer": "1.*",
"php": "^7.1"
},
"require-dev": {
"doctrine/cache": "1.*",
"phpunit/phpunit": "^7.5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Docblock Annotations Parser",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"docblock",
"parser"
],
"time": "2019-10-01T18:55:10+00:00"
},
{
"name": "doctrine/lexer",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/lexer.git",
"reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/lexer/zipball/5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6",
"reference": "5242d66dbeb21a30dd8a3e66bf7a73b66e05e1f6",
"shasum": ""
},
"require": {
"php": "^7.2"
},
"require-dev": {
"doctrine/coding-standard": "^6.0",
"phpstan/phpstan": "^0.11.8",
"phpunit/phpunit": "^8.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.",
"homepage": "https://www.doctrine-project.org/projects/lexer.html",
"keywords": [
"annotations",
"docblock",
"lexer",
"parser",
"php"
],
"time": "2019-10-30T14:39:59+00:00"
},
{
"name": "ircmaxell/password-compat",
"version": "v1.0.4",
"source": {
"type": "git",
"url": "https://github.com/ircmaxell/password_compat.git",
"reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/5c5cde8822a69545767f7c7f3058cb15ff84614c",
"reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c",
"shasum": ""
},
"require-dev": {
"phpunit/phpunit": "4.*"
},
"type": "library",
"autoload": {
"files": [
"lib/password.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anthony Ferrara",
"email": "ircmaxell@php.net",
"homepage": "http://blog.ircmaxell.com"
}
],
"description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash",
"homepage": "https://github.com/ircmaxell/password_compat",
"keywords": [
"hashing",
"password"
],
"time": "2014-11-20T16:49:30+00:00"
},
{
"name": "jolicode/ffi-uuid",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/jolicode/ffi-uuid.git",
"reference": "a2d823e36a5d0a14ef3413ffc105ea8818489f6e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jolicode/ffi-uuid/zipball/a2d823e36a5d0a14ef3413ffc105ea8818489f6e",
"reference": "a2d823e36a5d0a14ef3413ffc105ea8818489f6e",
"shasum": ""
},
"require": {
"ext-ffi": "*",
"php": "^7.4"
},
"type": "library",
"autoload": {
"psr-4": {
"JoliCode\\Uuid\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Baptiste Leduc",
"email": "baptiste.leduc@gmail.com"
},
{
"name": "Grégoire Pineau",
"email": "lyrixx@lyrixx.info"
}
],
"description": "Bind libuuid to PHP thanks to FFI",
"time": "2019-11-28T10:14:06+00:00"
},
{
"name": "lstrojny/functional-php",
"version": "1.10.0",
"source": {
"type": "git",
"url": "https://github.com/lstrojny/functional-php.git",
"reference": "809947093034cb9db1ce69b8b4536f4bbb6fe93e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lstrojny/functional-php/zipball/809947093034cb9db1ce69b8b4536f4bbb6fe93e",
"reference": "809947093034cb9db1ce69b8b4536f4bbb6fe93e",
"shasum": ""
},
"require": {
"php": "~7"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
"phpunit/phpunit": "~6",
"squizlabs/php_codesniffer": "~3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Functional\\": "src/Functional"
},
"files": [
"src/Functional/Average.php",
"src/Functional/ButLast.php",
"src/Functional/Capture.php",
"src/Functional/ConstFunction.php",
"src/Functional/CompareOn.php",
"src/Functional/CompareObjectHashOn.php",
"src/Functional/Compose.php",
"src/Functional/Concat.php",
"src/Functional/Contains.php",
"src/Functional/Converge.php",
"src/Functional/Curry.php",
"src/Functional/CurryN.php",
"src/Functional/Difference.php",
"src/Functional/DropFirst.php",
"src/Functional/DropLast.php",
"src/Functional/Each.php",
"src/Functional/Equal.php",
"src/Functional/ErrorToException.php",
"src/Functional/Every.php",
"src/Functional/False.php",
"src/Functional/Falsy.php",
"src/Functional/Filter.php",
"src/Functional/First.php",
"src/Functional/FirstIndexOf.php",
"src/Functional/FlatMap.php",
"src/Functional/Flatten.php",
"src/Functional/Flip.php",
"src/Functional/GreaterThan.php",
"src/Functional/GreaterThanOrEqual.php",
"src/Functional/Group.php",
"src/Functional/Head.php",
"src/Functional/Id.php",
"src/Functional/IfElse.php",
"src/Functional/Identical.php",
"src/Functional/IndexesOf.php",
"src/Functional/Intersperse.php",
"src/Functional/Invoke.php",
"src/Functional/InvokeFirst.php",
"src/Functional/InvokeIf.php",
"src/Functional/InvokeLast.php",
"src/Functional/Invoker.php",
"src/Functional/Last.php",
"src/Functional/LastIndexOf.php",
"src/Functional/LessThan.php",
"src/Functional/LessThanOrEqual.php",
"src/Functional/LexicographicCompare.php",
"src/Functional/Map.php",
"src/Functional/Match.php",
"src/Functional/Maximum.php",
"src/Functional/Memoize.php",
"src/Functional/Minimum.php",
"src/Functional/None.php",
"src/Functional/Not.php",
"src/Functional/PartialAny.php",
"src/Functional/PartialLeft.php",
"src/Functional/PartialMethod.php",
"src/Functional/PartialRight.php",
"src/Functional/Partition.php",
"src/Functional/Pick.php",
"src/Functional/Pluck.php",
"src/Functional/Poll.php",
"src/Functional/Product.php",
"src/Functional/Ratio.php",
"src/Functional/ReduceLeft.php",
"src/Functional/ReduceRight.php",
"src/Functional/Reindex.php",
"src/Functional/Reject.php",
"src/Functional/Repeat.php",
"src/Functional/Retry.php",
"src/Functional/Select.php",
"src/Functional/SelectKeys.php",
"src/Functional/SequenceConstant.php",
"src/Functional/SequenceExponential.php",
"src/Functional/SequenceLinear.php",
"src/Functional/Some.php",
"src/Functional/Sort.php",
"src/Functional/Sum.php",
"src/Functional/SuppressError.php",
"src/Functional/Tap.php",
"src/Functional/Tail.php",
"src/Functional/TailRecursion.php",
"src/Functional/TakeLeft.php",
"src/Functional/TakeRight.php",
"src/Functional/True.php",
"src/Functional/Truthy.php",
"src/Functional/Unique.php",
"src/Functional/With.php",
"src/Functional/Zip.php",
"src/Functional/ZipAll.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Lars Strojny",
"email": "lstrojny@php.net",
"homepage": "http://usrportage.de"
},
{
"name": "Max Beutel",
"email": "nash12@gmail.com"
}
],
"description": "Functional primitives for PHP",
"keywords": [
"functional"
],
"time": "2019-09-26T09:38:13+00:00"
},
{
"name": "paragonie/random_compat",
"version": "v9.99.99",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
"reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
"shasum": ""
},
"require": {
"php": "^7"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*",
"vimeo/psalm": "^1"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com",
"homepage": "https://paragonie.com"
}
],
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
"keywords": [
"csprng",
"polyfill",
"pseudorandom",
"random"
],
"time": "2018-07-02T15:55:56+00:00"
},
{
"name": "phpbench/container",
"version": "1.2",
"source": {
"type": "git",
"url": "https://github.com/phpbench/container.git",
"reference": "c0e3cbf1cd8f867c70b029cb6d1b0b39fe6d409d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpbench/container/zipball/c0e3cbf1cd8f867c70b029cb6d1b0b39fe6d409d",
"reference": "c0e3cbf1cd8f867c70b029cb6d1b0b39fe6d409d",
"shasum": ""
},
"require": {
"psr/container": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"PhpBench\\DependencyInjection\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniel Leech",
"email": "daniel@dantleech.com"
}
],
"description": "Simple, configurable, service container.",
"time": "2018-02-12T08:08:59+00:00"
},
{
"name": "phpbench/dom",
"version": "0.2.0",
"source": {
"type": "git",
"url": "https://github.com/phpbench/dom.git",
"reference": "b135378dd0004c05ba5446aeddaf0b83339c1c4c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpbench/dom/zipball/b135378dd0004c05ba5446aeddaf0b83339c1c4c",
"reference": "b135378dd0004c05ba5446aeddaf0b83339c1c4c",
"shasum": ""
},
"require": {
"ext-dom": "*",
"php": "^5.4|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.6"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"PhpBench\\Dom\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniel Leech",
"email": "daniel@dantleech.com"
}
],
"description": "DOM wrapper to simplify working with the PHP DOM implementation",
"time": "2016-02-27T12:15:56+00:00"
},
{
"name": "phpbench/phpbench",
"version": "0.16.10",
"source": {
"type": "git",
"url": "https://github.com/phpbench/phpbench.git",
"reference": "00c18b1ab87dbda66e8972c8602a14dd08c69914"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpbench/phpbench/zipball/00c18b1ab87dbda66e8972c8602a14dd08c69914",
"reference": "00c18b1ab87dbda66e8972c8602a14dd08c69914",
"shasum": ""
},
"require": {
"beberlei/assert": "^2.4 || ^3.0",
"doctrine/annotations": "^1.2.7",
"ext-dom": "*",
"ext-json": "*",
"ext-pcre": "*",
"ext-reflection": "*",
"ext-spl": "*",
"lstrojny/functional-php": "1.0 || ^1.2.3",
"php": "^7.1",
"phpbench/container": "~1.2",
"phpbench/dom": "~0.2.0",
"seld/jsonlint": "^1.1",
"symfony/console": "^3.2 || ^4.0",
"symfony/debug": "^2.4 || ^3.0 || ^4.0",
"symfony/filesystem": "^2.4 || ^3.0 || ^4.0",
"symfony/finder": "^2.4 || ^3.0 || ^4.0",
"symfony/options-resolver": "^2.6 || ^3.0 || ^4.0",
"symfony/process": "^2.1 || ^3.0 || ^4.0",
"webmozart/path-util": "^2.3"
},
"require-dev": {
"doctrine/dbal": "^2.4",
"friendsofphp/php-cs-fixer": "^2.13.1",
"padraic/phar-updater": "^1.0",
"phpstan/phpstan": "^0.10.7",
"phpunit/phpunit": "^6.5 || ^7.0"
},
"suggest": {
"ext-curl": "For (web) reports extension",
"ext-xdebug": "For Xdebug profiling extension."
},
"bin": [
"bin/phpbench"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"PhpBench\\": "lib/",
"PhpBench\\Extensions\\Dbal\\": "extensions/dbal/lib/",
"PhpBench\\Extensions\\XDebug\\": "extensions/xdebug/lib/",
"PhpBench\\Extensions\\Reports\\": "extensions/reports/lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniel Leech",
"email": "daniel@dantleech.com"
}
],
"description": "PHP Benchmarking Framework",
"time": "2019-09-01T08:08:02+00:00"
},
{
"name": "psr/container",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
"homepage": "https://github.com/php-fig/container",
"keywords": [
"PSR-11",
"container",
"container-interface",
"container-interop",
"psr"
],
"time": "2017-02-14T16:28:37+00:00"
},
{
"name": "psr/log",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801",
"reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2019-11-01T11:05:21+00:00"
},
{
"name": "ramsey/uuid",
"version": "3.8.0",
"source": {
"type": "git",
"url": "https://github.com/ramsey/uuid.git",
"reference": "d09ea80159c1929d75b3f9c60504d613aeb4a1e3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ramsey/uuid/zipball/d09ea80159c1929d75b3f9c60504d613aeb4a1e3",
"reference": "d09ea80159c1929d75b3f9c60504d613aeb4a1e3",
"shasum": ""
},
"require": {
"paragonie/random_compat": "^1.0|^2.0|9.99.99",
"php": "^5.4 || ^7.0",
"symfony/polyfill-ctype": "^1.8"
},
"replace": {
"rhumsaa/uuid": "self.version"
},
"require-dev": {
"codeception/aspect-mock": "^1.0 | ~2.0.0",
"doctrine/annotations": "~1.2.0",
"goaop/framework": "1.0.0-alpha.2 | ^1.0 | ~2.1.0",
"ircmaxell/random-lib": "^1.1",
"jakub-onderka/php-parallel-lint": "^0.9.0",
"mockery/mockery": "^0.9.9",
"moontoast/math": "^1.1",
"php-mock/php-mock-phpunit": "^0.3|^1.1",
"phpunit/phpunit": "^4.7|^5.0|^6.5",
"squizlabs/php_codesniffer": "^2.3"
},
"suggest": {
"ext-ctype": "Provides support for PHP Ctype functions",
"ext-libsodium": "Provides the PECL libsodium extension for use with the SodiumRandomGenerator",
"ext-uuid": "Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator",
"ircmaxell/random-lib": "Provides RandomLib for use with the RandomLibAdapter",
"moontoast/math": "Provides support for converting UUID to 128-bit integer (in string form).",
"ramsey/uuid-console": "A console application for generating UUIDs with ramsey/uuid",
"ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Ramsey\\Uuid\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marijn Huizendveld",
"email": "marijn.huizendveld@gmail.com"
},
{
"name": "Thibaud Fabre",
"email": "thibaud@aztech.io"
},
{
"name": "Ben Ramsey",
"email": "ben@benramsey.com",
"homepage": "https://benramsey.com"
}
],
"description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).",
"homepage": "https://github.com/ramsey/uuid",
"keywords": [
"guid",
"identifier",
"uuid"
],
"time": "2018-07-19T23:38:55+00:00"
},
{
"name": "seld/jsonlint",
"version": "1.7.2",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/jsonlint.git",
"reference": "e2e5d290e4d2a4f0eb449f510071392e00e10d19"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/e2e5d290e4d2a4f0eb449f510071392e00e10d19",
"reference": "e2e5d290e4d2a4f0eb449f510071392e00e10d19",
"shasum": ""
},
"require": {
"php": "^5.3 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0"
},
"bin": [
"bin/jsonlint"
],
"type": "library",
"autoload": {
"psr-4": {
"Seld\\JsonLint\\": "src/Seld/JsonLint/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "JSON Linter",
"keywords": [
"json",
"linter",
"parser",
"validator"
],
"time": "2019-10-24T14:27:39+00:00"
},
{
"name": "symfony/console",
"version": "v4.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "35d9077f495c6d184d9930f7a7ecbd1ad13c7ab8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/35d9077f495c6d184d9930f7a7ecbd1ad13c7ab8",
"reference": "35d9077f495c6d184d9930f7a7ecbd1ad13c7ab8",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php73": "^1.8",
"symfony/service-contracts": "^1.1|^2"
},
"conflict": {
"symfony/dependency-injection": "<3.4",
"symfony/event-dispatcher": "<4.3|>=5",
"symfony/lock": "<4.4",
"symfony/process": "<3.3"
},
"provide": {
"psr/log-implementation": "1.0"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "^3.4|^4.0|^5.0",
"symfony/dependency-injection": "^3.4|^4.0|^5.0",
"symfony/event-dispatcher": "^4.3",
"symfony/lock": "^4.4|^5.0",
"symfony/process": "^3.4|^4.0|^5.0",
"symfony/var-dumper": "^4.3|^5.0"
},
"suggest": {
"psr/log": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/lock": "",
"symfony/process": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Console\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2019-11-13T07:39:40+00:00"
},
{
"name": "symfony/debug",
"version": "v4.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "b24b791f817116b29e52a63e8544884cf9a40757"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/b24b791f817116b29e52a63e8544884cf9a40757",
"reference": "b24b791f817116b29e52a63e8544884cf9a40757",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"psr/log": "~1.0"
},
"conflict": {
"symfony/http-kernel": "<3.4"
},
"require-dev": {
"symfony/http-kernel": "^3.4|^4.0|^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Debug\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2019-11-10T17:54:30+00:00"
},
{
"name": "symfony/filesystem",
"version": "v4.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "d12b01cba60be77b583c9af660007211e3909854"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/d12b01cba60be77b583c9af660007211e3909854",
"reference": "d12b01cba60be77b583c9af660007211e3909854",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/polyfill-ctype": "~1.8"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Filesystem\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2019-11-12T14:51:11+00:00"
},
{
"name": "symfony/finder",
"version": "v4.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "ce8743441da64c41e2a667b8eb66070444ed911e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/ce8743441da64c41e2a667b8eb66070444ed911e",
"reference": "ce8743441da64c41e2a667b8eb66070444ed911e",
"shasum": ""
},
"require": {
"php": "^7.1.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Finder\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2019-11-17T21:56:56+00:00"
},
{
"name": "symfony/intl",
"version": "v5.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/intl.git",
"reference": "1a700ae25f25f1f7b2201da020184bff5a8912c0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/intl/zipball/1a700ae25f25f1f7b2201da020184bff5a8912c0",
"reference": "1a700ae25f25f1f7b2201da020184bff5a8912c0",
"shasum": ""
},
"require": {
"php": "^7.2.5",
"symfony/polyfill-intl-icu": "~1.0"
},
"require-dev": {
"symfony/filesystem": "^4.4|^5.0"
},
"suggest": {
"ext-intl": "to use the component with locales other than \"en\""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Intl\\": ""
},
"classmap": [
"Resources/stubs"
],
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
},
{
"name": "Eriksen Costa",
"email": "eriksen.costa@infranology.com.br"
},
{
"name": "Igor Wiedler",
"email": "igor@wiedler.ch"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "A PHP replacement layer for the C intl extension that includes additional data from the ICU library.",
"homepage": "https://symfony.com",
"keywords": [
"i18n",
"icu",
"internationalization",
"intl",
"l10n",
"localization"
],
"time": "2019-11-18T17:27:11+00:00"
},
{
"name": "symfony/options-resolver",
"version": "v4.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
"reference": "2be23e63f33de16b49294ea6581f462932a77e2f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/2be23e63f33de16b49294ea6581f462932a77e2f",
"reference": "2be23e63f33de16b49294ea6581f462932a77e2f",
"shasum": ""
},
"require": {
"php": "^7.1.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\OptionsResolver\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony OptionsResolver Component",
"homepage": "https://symfony.com",
"keywords": [
"config",
"configuration",
"options"
],
"time": "2019-10-28T21:57:16+00:00"
},
{
"name": "symfony/polyfill",
"version": "v1.13.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill.git",
"reference": "e81b4a674213c933467b61637629bf74adbce8fa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill/zipball/e81b4a674213c933467b61637629bf74adbce8fa",
"reference": "e81b4a674213c933467b61637629bf74adbce8fa",
"shasum": ""
},
"require": {
"ircmaxell/password-compat": "~1.0",
"paragonie/random_compat": "~1.0|~2.0|~9.99",
"php": ">=5.3.3",
"symfony/intl": "~2.3|~3.0|~4.0|~5.0"
},
"replace": {
"symfony/polyfill-apcu": "self.version",
"symfony/polyfill-ctype": "self.version",
"symfony/polyfill-iconv": "self.version",
"symfony/polyfill-intl-grapheme": "self.version",
"symfony/polyfill-intl-icu": "self.version",
"symfony/polyfill-intl-idn": "self.version",
"symfony/polyfill-intl-messageformatter": "self.version",
"symfony/polyfill-intl-normalizer": "self.version",
"symfony/polyfill-mbstring": "self.version",
"symfony/polyfill-php54": "self.version",
"symfony/polyfill-php55": "self.version",
"symfony/polyfill-php56": "self.version",
"symfony/polyfill-php70": "self.version",
"symfony/polyfill-php71": "self.version",
"symfony/polyfill-php72": "self.version",
"symfony/polyfill-php73": "self.version",
"symfony/polyfill-php74": "self.version",
"symfony/polyfill-util": "self.version",
"symfony/polyfill-uuid": "self.version",
"symfony/polyfill-xml": "self.version"
},
"require-dev": {
"symfony/phpunit-bridge": "~3.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\": "src/"
},
"files": [
"src/Apcu/bootstrap.php",
"src/Ctype/bootstrap.php",
"src/Php54/bootstrap.php",
"src/Php55/bootstrap.php",
"src/Php56/bootstrap.php",
"src/Php70/bootstrap.php",
"src/Php71/bootstrap.php",
"src/Php72/bootstrap.php",
"src/Php73/bootstrap.php",
"src/Php74/bootstrap.php",
"src/Iconv/bootstrap.php",
"src/Intl/Grapheme/bootstrap.php",
"src/Intl/Idn/bootstrap.php",
"src/Intl/Icu/bootstrap.php",
"src/Intl/MessageFormatter/bootstrap.php",
"src/Intl/Normalizer/bootstrap.php",
"src/Mbstring/bootstrap.php"
],
"classmap": [
"src/Intl/MessageFormatter/Resources/stubs",
"src/Intl/Normalizer/Resources/stubs",
"src/Php73/Resources/stubs",
"src/Php70/Resources/stubs",
"src/Php54/Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfills backporting features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compat",
"compatibility",
"polyfill",
"shim"
],
"time": "2019-11-27T16:56:11+00:00"
},
{
"name": "symfony/process",
"version": "v4.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "75ad33d9b6f25325ebc396d68ad86fd74bcfbb06"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/75ad33d9b6f25325ebc396d68ad86fd74bcfbb06",
"reference": "75ad33d9b6f25325ebc396d68ad86fd74bcfbb06",
"shasum": ""
},
"require": {
"php": "^7.1.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Process\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2019-10-28T20:30:34+00:00"
},
{
"name": "symfony/service-contracts",
"version": "v2.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
"reference": "9d99e1556417bf227a62e14856d630672bf10eaf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/9d99e1556417bf227a62e14856d630672bf10eaf",
"reference": "9d99e1556417bf227a62e14856d630672bf10eaf",
"shasum": ""
},
"require": {
"php": "^7.2.9",
"psr/container": "^1.0"
},
"suggest": {
"symfony/service-implementation": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Contracts\\Service\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Generic abstractions related to writing services",
"homepage": "https://symfony.com",
"keywords": [
"abstractions",
"contracts",
"decoupling",
"interfaces",
"interoperability",
"standards"
],
"time": "2019-11-09T09:18:34+00:00"
},
{
"name": "webmozart/assert",
"version": "1.6.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/assert.git",
"reference": "573381c0a64f155a0d9a23f4b0c797194805b925"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925",
"reference": "573381c0a64f155a0d9a23f4b0c797194805b925",
"shasum": ""
},
"require": {
"php": "^5.3.3 || ^7.0",
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
"vimeo/psalm": "<3.6.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36 || ^7.5.13"
},
"type": "library",
"autoload": {
"psr-4": {
"Webmozart\\Assert\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "Assertions to validate method input/output with nice error messages.",
"keywords": [
"assert",
"check",
"validate"
],
"time": "2019-11-24T13:36:37+00:00"
},
{
"name": "webmozart/path-util",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/path-util.git",
"reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/path-util/zipball/d939f7edc24c9a1bb9c0dee5cb05d8e859490725",
"reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"webmozart/assert": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.6",
"sebastian/version": "^1.0.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev"
}
},
"autoload": {
"psr-4": {
"Webmozart\\PathUtil\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "A robust cross-platform utility for normalizing, comparing and modifying file paths.",
"time": "2015-12-17T08:42:14+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"ext-uuid": "*"
},
"platform-dev": []
}
{
"bootstrap": "vendor/autoload.php"
}
#!/usr/bin/env bash
set -e
BASE=$(dirname $0)
if [[ ! -f $BASE/vendor/bin/phpbench ]]; then
composer install
fi
$BASE/vendor/bin/phpbench run $BASE/UuidBenchV1.php --report='{"extends": "aggregate", "cols": ["subject", "mean", "diff"]}'
$BASE/vendor/bin/phpbench run $BASE/UuidBenchV4.php --report='{"extends": "aggregate", "cols": ["subject", "mean", "diff"]}'
<?php
use JoliCode\Uuid\UuidGenerator;
use Ramsey\Uuid\Uuid as RamseyUuid;
use Symfony\Polyfill\Uuid\Uuid as SymfonyUuid;
/**
* @Revs(100000)
* @Iterations(5)
*/
class UuidBenchV1
{
private $ffi;
public function __construct()
{
$this->ffi = new UuidGenerator();
}
public function benchPecl()
{
uuid_create(UUID_TYPE_TIME);
}
public function benchSymfonyPolyfill()
{
SymfonyUuid::uuid_create(SymfonyUuid::UUID_TYPE_TIME);
}
public function benchJoliCodeFFI()
{
$this->ffi->v1();
}
public function benchRamsey()
{
RamseyUuid::uuid1();
}
}
<?php
use JoliCode\Uuid\UuidGenerator;
use Ramsey\Uuid\Uuid as RamseyUuid;
use Symfony\Polyfill\Uuid\Uuid as SymfonyUuid;
/**
* @Revs(100000)
* @Iterations(5)
*/
class UuidBenchV4
{
private $ffi;
public function __construct()
{
$this->ffi = new UuidGenerator();
}
public function benchPecl()
{
uuid_create(UUID_TYPE_RANDOM);
}
public function benchSymfonyPolyfill()
{
SymfonyUuid::uuid_create(SymfonyUuid::UUID_TYPE_RANDOM);
}
public function benchJoliCodeFFI()
{
$this->ffi->v4();
}
public function benchRamsey()
{
RamseyUuid::uuid4();
}
}
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.