3 main reasons to benchmark Java code
3 main reasons to benchmark Java code.
- 1. To see if your JVM is performing well
- 2. To see if your code is performing well
- 3. To see if your code is running the way you think it should be running
- My personal opinion is that the second is the best reason to benchmark. You should always try to measure the performance (throughput) of your application with a benchmark tool before making any changes to the code. Be sure to write the benchmark test so that you can run it before you make any changes as well as after you make changes.
- A good example of this is the concurrency changes in JDK 5.0. Concurrency can make performance problems difficult to track down and optimize. Benchmarking is the only way to be sure that you are getting the performance gains you thought you would get.
- Perform benchmarking by writing a test case that is as close to your real code as possible. Make sure that you have the same data set and same data flow in the benchmark test. Make sure that you run the benchmark test multiple times and average the results to get the best results possible.