Optimizing Program Performance-- Summary, Performance Improvement Techniques

本文介绍了提高程序性能的基本策略,包括选择合适的算法和数据结构、避免过度函数调用、减少不必要的内存引用等高级设计原则,以及尝试不同的指针和数组代码、展开循环等底层优化技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Although we have only considered a limited set of applications, we can draw important lessons on how to
write efficient code. We have described a number of basic strategies for optimizing program performance:


1. High-level design. Choose appropriate algorithms and data structures for the problem at hand. Be especially
vigilant to avoid algorithms or coding techniques that yield asymptotically poor performance.

选择高效的算法。

2. Basic coding principles. Avoid optimization blockers so that a compiler can generate efficient code.
(a) Eliminate excessive function calls. Move computations out of loops when possible. Consider
      selective compromises of program modularity to gain greater efficiency.
(b) Eliminate unnecessary memory references. Introduce temporary variables to hold intermediate
     results. Store a result in an array or global variable only when the final value has been computed.

 

3. Low-level optimizations.
(a) Try various forms of pointer versus array code.
(b) Reduce loop overhead by unrolling loops.
(c) Find ways to make use of the pipelined functional units by techniques such as iteration splitting.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值