By ekabanov
via dow.ngra.de
Published: Aug 04 2008 / 08:10
IP2C is a small library that provides IP to country resolution. It uses the free ip-to-country database. There is a PHP and Java frontends to query the database, but PHP implementation is embarrassingly slower (at least an order of magnitude!). Can we do better or is this a basic limitation of the platform?
Comments
phpimpact replied ago:
You linked to Computer Language Benchmarks without even knowing the version of PHP they are running.
toomasr replied ago:
PHP 5.2.2-pl1-gentoo (cli) (built: May 8 2007 09:51:53) says on the Computer Language Benchmarks. I guess PHP 5.2.6-2+b1 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 22 2008 21:03:43) and 5.2.2 are quite close. Am I mistaken?
phpimpact replied ago:
You are right, I missed that, thanks
scriptone replied ago:
You’re comparing a JIT’d VM based language versus an interpreted dynamically typed scripting language? And you’re shocked the performance is so off? What's next, C++ vs Javascript? OMG...
Embarrassing case study.
eitland replied ago:
Seems like the server is down.
Jevgeni Kabanov replied ago:
We keep bringing it up, but we are hitting some artificial limits like kmemsize imposed by the hosting :(
Gregg Bolinger replied ago:
This was a great post. Not because of the results but because of how the results were obtained. Seemed quite unbiased to me, which I like. Thanks.
dmitryx replied ago:
such a comparison is idiocy by definition
Jevgeni Kabanov replied ago:
Such a statement is idiocy by definition.
phpimpact replied ago:
Jevgeni, no reason to start a flame war in this site. That's not why we are here. We all know that php, just like ruby and python, is slower than java. And to be honest, the only embarrassing thing here was you comment, as opposed to your benchmark.
Jevgeni Kabanov replied ago:
It's not my benchmark, I just posted it here. And two orders of magnitude *is* embarrassingly slower. So if someone calls it idiocy I'd like to see some argumentation.
phpimpact replied ago:
It looks to me that you forgot to enable opcode cache, trust me, it reduce the time it takes to compile the code by up to 90%. PHP is an interpreted language. This means that each time a PHP generated page is requested, the server must read in the various files needed and "compile" them into something the machine can understand (opcode).
Also, there are alternatives to the standard PHP interpreter, so if you consider the standard to be slow, try benchmarking your code with another interpreter.
So, for me to take your results seriously, you need to: 1) Benchmark your code with opcode cache enabled, or 2) Benchmark it with different interpreters.
ivo_danihelka replied ago:
no need to be rude
Voters For This Link (13)
Voters Against This Link (3)