Basic knowledge of Java Program Performance Tuning and JDK tuning

Source: Internet
Author: User

A basic knowledge

1.1 What is the performance

Before performance tuning, let's first look at what performance is. As for performance, I think everyone who has studied Java can list a few points or even talk about it. In the book "Java TM Platform Performance", the following five aspects are defined as criteria for evaluating performance:

1 performance of the operation-which algorithm is the best performing performance?

2 memory allocation-How much memory does the program need to run?

3 Start-up time-how long will the program start? This has little impact on web projects, but be aware of situations where some programs need to be deployed or run on the client (such as applet programs).

4 scalability of the program-what is the performance of the program in the case of a pressure load?

5 Performance perception--under what circumstances will the user feel the performance of the program is not good?

The above five aspects, in the concrete use scene may have the choice to judge. As for these five aspects of performance tuning, in the subsequent chapters will be given to the corresponding performance tuning strategy.

1.2 Rules for tuning

We just need to be concerned about the performance issues that affect our programs, and what we perceive, rather than each of the methods in each class, we need to do something to improve performance. If the performance of the program does not meet the requirements we expect, we need to consider how to optimize performance. Similarly, obscure code can improve the performance of the program, but at the same time it may bring us a maintenance nightmare. We need to compromise on both of these situations, so that the code of the program is graceful and fast enough to meet the customer's desired performance requirements.

Optimizing the code can even lead to undesirable results, Donald Knuth (a comparison of the impact of cattle, the specific who, I also forget, who knows, can tell me, thank you!) ) once said, "Premature optimization is the root of all evil". Before you start performance tuning, you need to point out some reasons for not optimizing your code.

1 if the optimized code is working properly, a new bug may be introduced after optimization;

2 Optimizing the code tends to make the code more difficult to understand and maintain;

3 code optimized on one platform may be worse on another platform;

4) spend a lot of time on the optimization of code, improve a little performance, but led to obscure code. Indeed, before we optimize, we must carefully consider whether it is worthwhile to optimize.

1.3 Steps for tuning

Generally, we can improve the performance of our application by dividing the following steps:

1 Clear the performance of the application indicators, how to meet the expected performance requirements;

2) testing on the target platform;

3 If the performance has reached performance indicators, Stop;

4 Find performance bottlenecks;

5) Modify performance bottleneck;

6) Return to step 2nd.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.