There are newer benchmarks: C++ vs. Python vs. PHP vs. Java vs. Others performance benchmark (2016 Q3)
The benchmarks here do not try to be complete, as they are showing the performance of the languages in one aspect, and mainly: loops, dynamic arrays with numbers, basic math operations.
This is a redo of the tests done in previous years. You are strongly encouraged to read the additional information about the tests in the article.
Here are the benchmark results:
|Language||CPU time||Slower than||Language
|C++ (optimized with -O2)||0.952||0.172||1.124||–||–||g++ 5.3.1||link|
|Java 8 (non-std lib)||1.332||0.096||1.428||27%||27%||1.8.0_72||link|
|Python 2.7 + PyPy||1.560||0.160||1.720||53%||20%||PyPy 4.0.1||link|
|C++ (not optimized)||2.988||0.168||3.156||181%||55%||g++ 5.3.1||link|
The clear winner among the script languages is… PHP 7. 🙂
Yes, that’s not a mistake. Apparently the PHP team did a great job! The rumor that PHP 7 is really fast confirmed for this particular benchmark test. You can also review the PHP 7 infographic by the Zend Performance Team.
Brief analysis of the results:
- NodeJS got almost 2x faster.
- Java 8 seems almost 2x slower.
- Python has no significant change in the performance. Every new release is a little bit faster but overall Python is steadily 15x slower than C++.
- Perl has the same trend as Python and is steadily 22x slower than C++.
- PHP 5.x is the slowest with results between 47x to 60x behind C++.
- PHP 7 made the big surprise. It is about 10x faster than PHP 5.x, and about 3x faster than Python which is the next fastest script language.
The tests were run on a Debian Linux 64-bit machine.
You can download the source codes, an Excel results sheet, and the benchmark batch script at: