Closed SimonDeconde closed 8 years ago
I wouldn't say you are missing anything, but there are a couple of ways to improve performance:
Hi Oschwald
Thanks for your reply.
My example code was written for simplicity, but even without opening/closing the database for every lookup the performance difference can be seen. Based on both 1) a more advanced benchmark (2000 ip lookup loops) and 2) a real application where I import visitor geolocation (millions of lookups), I'm still seeing a 3x slower lookup time than with the legacy library (DB is opened/closed only once).
Based on your experience, is that normal that this library is slower than the legacy one? If so, is there a specific technical reason?
I've indeed heard about the C extension, but I wanted to compare the two libraries/formats based on pure-PHP solutions. Would you say that this new library + C extension is faster than the old library + C extension?
Thanks for your help!
Yes, it is expected that the new format will be slower. The new database contains quite a bit more information that gets read out of the database during the request and the search tree is deeper as the new format supports IPv6 in the same database as IPv4. Although we did not provide a C extension ourselves for the old format, I would suspect that the PECL one for the old format is also faster than the official extension for the new format.
Thanks for the details Gregory!
Hi there
I've been comparing this library to the legacy geoip-api-php (https://github.com/maxmind/geoip-api-php) in terms of lookup speed. I've read that the new format (.mmdb) is supposed to offer faster lookups than the old format (.dat), however my tests show the opposite, with way slower lookups.
Consider the below code:
Execution trace:
Am I missing something here?