Java Performance Tuning Tips
Performance optimization is a complex exercise and require due diligence before starting. Do your initial analysis. Use a profiler on your application first to figure out which areas are taking more time than expected. Took the bigger one first and start working on them. Following are few of the techniques specific to java performance tuning.
- Use StringBuilder to concatenate Strings if your code area is thread-safe.
- Use + operator to concatenate strings if it is in single statement.
- Use primitives as much as possible instead of wrapper classes.
- Use long, double instead of BigNumber or BigDecimal if possible.
- Check log level, it should be info for production level instance of your application.
- Use caching to cache database connections or heavy objects.
- Use Apache commons StringUtils.replace instead of String.replace. As former is much faster.
- Try optimizing read(), write() calls during file I/O.
- Increase buffer size if large memory is available.
Published on 19-Jan-2018 18:05:46