"Programming techniques to improve C + + performance" Reading note 1-Introduction

Source: Internet
Author: User

"The end of the paper is light."


Recently began to read this book, standing on the shoulders of giants, hope to have a greater harvest!!


The execution efficiency of a program is determined by the number of machine instructions that are executed after the program is translated into assembly language. and the execution cycle of each machine instruction is certain. C and C + + are higher than assembly language high-level languages, where the C language source code and its corresponding machine is not exactly the same, but roughly linear, but the source code of C + + language and the cost of compiling code varies greatly. A C + + directive may correspond to 3 assembly instructions, while another may correspond to 300. Because of this, most of the time we write the code itself is inefficient, this can not be completely blamed on the C + + language itself, then the real software inefficiencies and where?


Software performance

Efficiency of design efficiency coding

Algorithm and data structure, program decomposition language structure, system architecture, library, compiler optimization


To be sure, the efficiency of the software is determined by the efficiency of the design and the efficiency of the coding, in which the efficiency of the design is related to the high-level design of the program, that is to say you have the ability to grasp the overall situation, to a large extent, this is not related to the language itself, no matter how efficient language can not compensate for

Referring to the global design, data structure and algorithm design is to be mentioned. The optimal design of algorithms and data structures is absolutely necessary for software performance. Second, the program decomposition, is the entire program decomposition into several different modules, the interaction between the modules, as well as the design of each module.

After completing these necessary designs, the efficiency of the coding is put on the agenda, and the language structure is the effect of some of the overhead of the language itself on the performance of the program. System architecture, regardless of the development of the architecture is useless. The real world does not have infinite memory, unlimited computing power, parallel threading execution, and the assumption that code is doomed to rot. Therefore, we must bear in mind that the "memory is not infinite", "Memory access overhead is not balanced, the access time for different storage media is an order of magnitude difference", "our program does not have a dedicated CPU", "on a single-processor computer, parallel programs can only be polled." 3rd, is the choice of the library, the library function is the implementation of the re-reuse, which for performance must have a compromise, so in the face of the performance of the code snippet, the implementation of their own can not be. Finally, the compiler is the problem, the compiler's optimization technology is also the point of impact program performance. However, it is absolutely essential to remember not to rely on compiler optimizations, but to write inefficient code that should try not to rely on compiler optimizations.


The above factors are the points that affect the performance of the program, but also the programmer who is determined to write efficient code should always remember.

Read the introduction today, the proceeds quite abundant, soon can begin to read this book, expect C + + Bring me more surprises!!!

"Programming techniques to improve C + + performance" Reading note 1-Introduction

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.