Still obsessing over stupid benchmarks …

The problem. The PHP implementation is a lot slower. Embarrassingly slower. Without any caching the Java version is able to do ~6000 queries per second. The PHP counterpart can push through ~850 queries. The implementations are the same. The stats provided by the author of the library are 8000 vs 1200. So about the same as my measurements.

Via reddit.com [1], “Case study: Is PHP embarrasingly slower than Java? [2]”

In my ever continuing obsession with stupid benchmarks and optimization [3], I decided to tackle this particular little problem like I did with Jumble [4]—map everything into memory and avoid disk I/O (Input/Output) altogether (well, explicit disk I/O—the system will page in the data implicitly as it's used). This time, the data [5] maps down to an object file about 8½ megabytes in size (all constant data, so pages can be discarded, not paged out), and with that, I was able to get ~100,000 queries per second.

On a 120MHz (megaHertz) machine!

It didn't even take all that long to write …

[1] http://www.reddit.com/r/programming/comments/6usfd/case_study_is_php_em

[2] http://dow.ngra.de/2008/08/04/optimizing-ip2c-php-implementation/

[3] /boston/2007/11/30.1

[4] /boston/2008/06/27.1

[5] http://ip-to-/

Gemini Mention this post

Contact the author