Alex Rivera | Logout

Speeding Up Java

Asked 2008-10-07T18:28:03.470
15

This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together:

  • Firstly: Given an established Java project, what are some decent ways to speed it up beyond just plain in-code optimization?

  • Secondly: When writing a program from scratch in Java, what are some good ways to greatly improve performance?

Please stay away from general optimization techniques unless they are Java specific.

I asked this about Python and Perl earlier. For Java I'm wondering what good tips/tricks are out there to improve performance and if there are any particularly good Java profilers.

Edit
Report

2 Answers

5

Using StringBuilder in place of large sets of String concatenation gives a great relative performance boost.

However, I can't avoid saying the general practice performance gaining benefit, Profiling. I don't know Java profiling off-hand (Only used the language academically), but profiling helps you identify problem sections of your code, and it is a lot easier to fix specific sections since you have something to look up.

answered 2008-10-07T18:31:47.160
1

Java 1.6_07+ comes with its own profiler. It is called Java VisualVM. Just type jvisualvm on the command prompt if you have your %JAVA_HOME%/bin on your PATH.

answered 2008-10-07T20:15:16.080

Your Answer