Java adds numbers really fast

Daniel Lemire has posted a tiny benchmark for a basic part of many numerical applications: a loop that sums up numbers in an array. The astonishing part is the performance of Oracle Java 7 which dramatically outperforms an older GCC version, and keeps up quite well with newer compilers! I tested the same code against Visual Studio 2010’s C# and C++ compilers, and found that Java outperformed both by a factor of three.

While this particular result is an outlier, Java’s ability to keep up with C++ is not. Numerical researchers have been gradually adopting Java for a while now, as the diminishing potential speedup of C++ rarely warrants its vastly greater language complexity.

2013-11-16: Jian Zhen ran a similar benchmark that compares Daniel Lemire’s Java PFOR library against his own Go port. He found that natively compiled Go couldn’t beat the OpenJDK 7 Server VM, not even by loop unrolling or disabling bounds checking.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.