10'000 iterations with pecl-uuid: 1.0.3+
, rhumsaa/uuid: 2.8
and ramsey/uuid: 3.0
implementations.
$ pecl install uuid
$ melody run uuid-benchmark.php
# no melody overhead for profiling
$ composer install && php uuid-benchmark.php
Results of benchmark:
PECL | 0.0360 sec/10000 | 0.0000036 sec/one
RHUMSAA | 0.0740 sec/10000 | 0.0000074 sec/one
RAMSEY | 0.1840 sec/10000 | 0.0000184 sec/one
I'm actually suspecting the performance drop is due to the way the PeclUuidFactory is implemented: it checks on every call to uuidX() which method to use (pure PHP vs pecl) which probably creates a major overhead due to all the JMP's, though I may be wrong (I haven't checked the generated opcode's and cant tell much from the call graph).
I'll run some tests with an updated implementation that does not branch to see if that resolves the issue.