-1

I have a quite large Java application, that I may thinking to do some performance increase, but I am very new at this and wonder where should I start.

I guess I have to first perform some code test and see where most calculation and resource/time spend on which part of code before starting increase performance. Are there any tool that I can use and any general tips where to start and how to increase performance?

user2412555
  • 1,055
  • 1
  • 16
  • 32
  • 2
    Luke, use the _profiler_ - said Yoda. (check out jProfiler) – ppeterka Oct 03 '13 at 08:30
  • You should start by profiling your application... You can then decide which areas you need to optimize. And consider load and stress testing as well. – Thihara Oct 03 '13 at 08:30

2 Answers2

1

You may take a look at this:

Performance profiler for a java application

And find bottleneck of your application.

Without further info, there is not much to say. Some general advice for performance issues:

  • Do not put if inside loops, if it can be outside

  • Try avoid extensive use of division operator

  • Cache data instead of loading them all over again from files / DB

  • Recursion may be faster if rewritten to loops

  • If you now sizes of "lists" beforehead, no not use add, but resize your array during initialization

  • Use threads were possible and where thread could perform large portion (or slow) of code. Do not use threads if you only need to fill array with max of tousands elements.

Community
  • 1
  • 1
Martin Perry
  • 9,232
  • 8
  • 46
  • 114
1

First, if you have lots of loops, think carefully about whether you need to run through every single loop. Maybe you can combine some of them?

Second, don't create variables unless you have to. If you have a complex mathematical equation, write it out split up into lots of variables to make it easier to debug, but remember to combine it into one or two lines when you're finished.

Finally, use one of the many free open-source Java profilers.

Clonkex
  • 3,373
  • 7
  • 38
  • 55