DEV Community

Discussion on: 9 tips to Increase your Java performance β˜•οΈ πŸš€ πŸšΆβ€β™‚οΈ

Collapse
 
sendilkumarn profile image
Sendil Kumar

Applying these "performance improvements" to your code will have little to no impact.

Again and yet again, I am reiterating here


Note: The JVM optimizes the code efficiently. So you do not need to optimize it for a general use cases. But if you want to drain the maximum performance out of JVM. Here we go.

Performance improvement suggestions should be accompanied with why one performs better than the other.

Yeah we can explain each one of them. Show the difference in the byte code and how JVM optimizes them and things like that (Maybe in future (when I have time))

new HashSet<>(list.size()).addAll(list);

I would be surprised, if they are not almost identical.

So if you refactor your large method to 3 smaller methods, and 1 medium method. Then your 3 small methods might be optimized at some point, and make your code faster than.

Create smaller methods, of course is in every clean code / perf optimization book.

But look out this when running on smaller devices, sometimes too many smaller methods will result in more inlining that will increase the memory pressure.

Collapse
 
sendilkumarn profile image
Sendil Kumar

Thanks for the Optimizing Java book