TamTam - Java 8 functional programming: don't neglect optimisations!

Functional Java 8 new features aims to ease development. But we will see that you still need to deeply understand them internally, especially in the case of micro-benchmarking.

The original article from Tapiki is claiming that Java 8 Lambdas and Streams can be 5 times slower: Benchmark: How Java 8 Lambdas and Streams Can Make Your Code 5 Times Slower. Concluding that using functional programing may be a flaw in your code if you need performance.

But someone (ybonnel) proposed a pull request with many fixes on code (replacement of functions like Integer.max(), avoid unnecessary boxing/unboxing, etc.). Now performance is similar between Imperative and Functional programing (see : https://github.com/takipi/loops-jmh-playground/pull/2).

Conclusion: micro-benchmarking is a very difficult art in programming, especially with brand new features. Coding is particularly error prone since you need deep understanding to be fair.


Vous avez trouvé cette publication utile? Cliquer sur