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.
Here are the benchmark results:
|Language||CPU time||Slower than||Language
|C++ (optimized with -O2)||0.899||0.053||0.951||–||–||g++ 6.1.1||link|
|Java 8 (non-std lib)||1.090||0.006||1.096||15%||6%||1.8.0_102||link|
|Python 2.7 + PyPy||1.376||0.120||1.496||57%||36%||PyPy 5.4.1||link|
|C# .NET Core Linux||1.583||0.112||1.695||78%||13%||1.0.0-preview2||link|
|C++ (not optimized)||2.921||0.054||2.975||212%||9%||g++ 6.1.1||link|
|Java 8 (see notes)||12.064||0.080||12.144||1176%||83%||1.8.0_102||link|
The big difference this time is that we use a slightly modified benchmark method. Programs are no longer limited to just 10 loops. Instead they run for 90 wall-clock seconds, and then we divide and normalize their performance as if they were running for only 10 loops. This way we can compare with the previous results. The benefit of doing the tests like this is that the startup and shutdown times of the interpreters should make almost no difference now. It turned out that the new method doesn’t significantly change the outcome compared to the previous benchmark runs, which is good as the old way of benchmarks seems also correct.
Brief analysis of the results:
- Rust, which we benchmark for the first time, is very fast. 🙂
- C# .NET Core on Linux, which we also benchmark for the first time, performs very well by being as fast as NodeJS and only 78% slower than C++. Memory usage peak was at 230 MB which is the same as Python 3.5 and PHP 7.0, and two times less than Java 8 and NodeJS.
- NodeJS version 4.3.x
got much slower than the previous major version 4.2.x. This is the only surprise.It turned out to be a minor glitch in the parser which was easy to fix. NodeJS 4.3.x is performing the same as 4.2.x.
- Python and Perl seem a bit slower than before but this is probably due to the fact that C++ performed even better because of the new benchmark method.
- Java 8 didn’t perform much faster as we expected. Maybe it gets slower as more and more loops are done, which also allocated more RAM.
- Also review the analysis in the old 2016 tests for more information.
The tests were run on a Debian Linux 64-bit machine.
You can download the source codes, raw results, and the benchmark batch script at:
Update @ 2016-10-15: Added the Rust implementation. The minor versions of some languages were updated as well.
Update @ 2016-10-19: A redo which includes the NodeJS fix.
Update @ 2016-11-04: Added the C# .NET Core implementation.