Refactoring and performance of "Refactoring learning" 01

Source: Internet
Author: User

Refactoring doesn't mean better performance, but refactoring can make performance optimizations easier!!!

about writing high-performance code

Prerequisites for writing high-performance code: first you have to have a program that can be adjusted.

Just as people ask you how to get along with your girlfriend, first you have to have a girlfriend.

Ways to write high-performance code:

  1. Time Budget Law

Allocate a certain amount of resources to each component-including time and execution trajectories-and each component cannot exceed its own budget.

Typically used for very demanding real-time systems.

  2. Continuous attention to law

This approach requires any programmer to do anything at any time to ensure the performance of the system.

This approach is common and feels appealing, but it usually doesn't work too much. (written by the author of the refactoring)

Any modification to improve performance usually makes the program difficult to maintain and slows down development.

And once the performance improvement is dispersed to every corner of the program, every improvement is just a narrow point of view of the program's behavior.

A program usually consumes more than a half of the events in a half code, and if you optimize all the code equally, 90% of the optimizations are white, because your optimized code is seldom executed.

You take the time to make the program run faster, and if you lack the clarity of the program and spend time, that time is wasted.

  3, the Hot promotion method (my name)

With this approach, writing code does not require special attention to performance until it enters the performance optimization phase-usually in the late stages of development.

During the performance optimization phase:

First, a measure tool to monitor the operation of the program, to find a lot of time and space-consuming code, that is, "hot".

Then to optimize these hotspots, you can spend less time to achieve better optimization effect

  About refactoring Help for performance optimization

first of all, a well-constructed code gives you plenty of time for performance tuning because it allows you to add functionality more quickly and more time on performance issues (accurate metrics   Make sure you spend the time in the right place).

Second, in the face of a well-structured program, you have a finer granularity in performance analysis, so the measurement tool will take you into a smaller range of procedural paragraphs, and the performance of the adjustment is relatively easy. Because the code is clearer, you can better understand your choices and be more aware of which adjustments play a key role.

  

                                                      

 

  

  

  

  

Refactoring and performance of "Refactoring learning" 01

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.