Benchmarks
Large-candidate benchmark
Dataset: 5,000,000 hashes.
| Benchmark | Limit | Time |
|---|---|---|
| Large candidate search | 20 | 548.238ms |
| Large candidate search | 1000 | 540.776ms |
| Large candidate search, no limit effect | unlimited | 4.570s |
What this means
Looking for the best matches?
Finding the top 20 or top 1000 similar images takes around half a second, even with five million hashes indexed.
Why is unlimited slower?
When no limit is applied, the extension must continue processing and sorting every possible match. Most real-world applications only need the closest matches.
Index performance
Benchmarked with 500 precomputed dHashes.
| Operation | Time | Approx throughput |
|---|---|---|
| Add 500 hashes | 0.27 ms | ~1.85M ops/sec |
| Search 500 hashes | 0.50 ms | ~1M ops/sec |
| Add + Search | 0.51 ms | ~980K ops/sec |
| Save + Load Index | 12 ms | ~83 ops/sec |
What this means
Building an index is extremely fast.
Adding hashes is effectively instantaneous for normal workloads. Millions of hashes can be imported in minutes rather than hours.
Searches are designed for interactive use.
The extension is fast enough to power web applications, APIs and security tooling without requiring a separate search service.
Indexes can be saved and restored quickly, making it practical to pre-build indexes and load them at application startup.
Hash generation benchmark
| Tool | dHash | dHash throughput | pHash | pHash throughput |
|---|---|---|---|---|
php_imagehash | 2.316s | ~216 hashes/sec | 2.425s | ~206 hashes/sec |
Python ImageHash | 4.168s | ~120 hashes/sec | 5.184s | ~96 hashes/sec |
jenssegers/imagehash | 7.168s | ~70 hashes/sec | 12.177s | ~41 hashes/sec |
What this means
Faster image processing.
php_imagehash generates hashes roughly 2× faster than Python ImageHash and up to 5× faster than the popular pure-PHP implementation.
Less waiting during imports.
When processing large image collections, hash generation is often the bottleneck. Faster hashing means datasets can be indexed significantly sooner.
The extension performs the heavy lifting in Rust rather than PHP userland, reducing overhead while keeping a simple PHP API.
