在学习csapp, 看完了第五章。标记一下, 所以直接引用csapp书中内容了:
Life in the Real World: Performance Improvement Techniques
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.

本文总结了《计算机网络自顶向下方法》第五章中的性能改进技术。从高级设计选择合适的算法和数据结构,到基本编码原则如减少不必要的内存引用,再到低级优化如循环展开等。这些策略有助于编写更高效的代码。
1886

被折叠的 条评论
为什么被折叠?



