The repository at v2.0.1 ships no published benchmark figures. The 2.0.0 release removed the performance claims from the README because they were unsubstantiated. Measure on your own hardware.
Uuid::benchmark()
use Webpatser\Uuid\Uuid; $result = Uuid::benchmark(10000, 7);
The result contains:
| Key | Meaning |
|---|---|
version |
UUID version measured |
iterations |
Number of UUIDs generated |
total_time_ms |
Total time in milliseconds |
avg_time_us |
Average time per UUID in microseconds |
memory_used_bytes |
Change in memory_get_usage(true) |
uuids_per_second |
Throughput |
For versions 3 and 5 the benchmark uses the name benchmark in Uuid::NS_DNS.
Run it live
Pick a version and an iteration count and run Uuid::benchmark() on this server. The figures are measured just now on this server's hardware. They are not a comparison with other libraries, and runs are rate limited per visitor.
Runs on demand, at most 5 times a minute per visitor.
This demo runs webpatser/uuid 3.0.0, the version installed on this site.
Benchmark script
php examples/benchmark.php 10000
The script runs versions 1, 3, 4, 5, 6, 7 and 8, prints a table, and compares versions 4 and 7 with ramsey/uuid when it is installed:
composer require --dev ramsey/uuidphp examples/benchmark.php 10000
Implementation notes
- Random bytes come from
Random\Randomizer. - Version 7 embeds a per-process counter in the bits after the timestamp, so UUIDs created in the same millisecond by one process sort in creation order (up to 256 per millisecond; not across processes).
- The string form and
uuid_orderedare computed once in the constructor; the other properties are computed on access from the stored 16 bytes.