Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How C++ optimizes the code

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how C++ optimizes the code". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Per.1: there is no clear reason not to optimize

Reason (reason)

If there is no need for optimization, the main result of the effort will be more errors and higher maintenance costs.

Without optimized requirements, the biggest result of this effort is more errors and higher maintenance costs.

Note (Note)

Some people optimize out of habit or because it's fun.

Some people are just in the habit or interest to optimize.

Per.2: Don't optimize prematurely

Per.2: don't optimize your code too early

Reason (reason)

Elaborately optimized code is usually larger and harder to change than unoptimized code.

Code that takes effort to optimize is usually larger and more difficult to modify than unoptimized code.

Per.3: Don't optimize something that's not performance critical

Per.3: don't optimize code with low performance requirements

Reason (reason)

Optimizing a non-performance-critical part of a program has no effect on system performance.

Optimizing code with low performance requirements is not helpful to system performance.

Note (Note)

If your program spends a lot of time jam waiting for web pages or user input, optimizing in-memory computing performance is likely to have little effect. Take another route: if your program spends 4% of the CPU time due to calculating A, and 40% of the CPU time is calculated by the user, improving A's performance by 50% will only be equivalent to 5% of B's performance improvement. (if you don't even know how much CPU time An and B consume, see Per.1 and Per.2)

This is the end of the content of "how C++ optimizes the code". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report