Wednesday, February 23, 2011

PHP faster than Python?

I know it's been a while since the last time i posted in this blog. Out of technicality little bit, just to express my shocked, and disbelieved with OSCC benchmark report between PHP and Python.

OSCC Benchmark PHP vs Python.

Try to download it and read. My first remark while going through: "they are comparing non object oriented language with a fully object oriented language"

Take look at this:

Language Shoot Out
This OO Benchmark PHP/Python/Perl/Ruby
and This

and quote from one of the link above

Even Rasmus Lerdorf, the creator of PHP, admits this. In this interview from SitePoint, Rasmus is asked about how to make PHP fast. He answers "Well, you can't".

I leave the rest "à vous".

Edited: The puzzle some how answered, thanks EAFaisal for clearing this out. (under comments)

1 comment:

eafaisal said...

Looking at the codes, it's not apple-to-apple comparison. The datetime module in Python is comparable to DateTime class in PHP. In order to match against PHP microtime(), the test should use time module (time.time()) in Python.

So, I tested on my old, underspec desktop for script 1 and 4, changing datetime to time.time(), I got these results (average of 3 runs):
1. Script 1 - 2.4154 sec
2. Script 4 - 0.000155 sec

Those results not only beat the corresponding Python results in the paper, but better from the PHP results (no pun intended).