chapter 5

Posted 孤灯下的守护者

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了chapter 5相关的知识,希望对你有一定的参考价值。

5.4 Eliminating loop inefficiencies

A general class of optimizations is known as code
motion. They involve identifying a computation that is
performed multiple times,(e.g.,within a loop), but such
that the result of the computation will not change.

5.5 Reducing Procedure Calls

5.6 Elimiating Unneeded Memory References


5.13 Performance improvement techniques

For optimizing program performance:

High-level design:

Choose appropriate algorithms and data structures.

Basic coding principles:

+ Eliminate excessive function calls.
+ Eliminate unnecessary memory references. Introduces
temporary varibles to hold intermediate results.

Low-level optimizations, Structure code to take advan-
tage of the hardware capabilities:

+ Unroll loops to reduce overhead and to enable fur-
ther optimizations.
+ Find ways to increase instruction-level parallelism
by techniques such as multiple accumulators and
reassociation.
+ rewrite conditional operations in a functional
style to enable compilation via conditional data
transfers.

5.14.1 Program profiling

Profiling with GPROF requires three steps:

# -pg to ensure compiler does not do any optimizes.
1. gcc -Og -pg prog.c -o prog
2. executed as usual:
./prog
3. GPROF is invoked to analyze the data in gmon.out
gprof prog

以上是关于chapter 5的主要内容,如果未能解决你的问题,请参考以下文章

《JavaScript高级程序设计》Chapter 15 canvas + Chapter 16 HTML5

《Dive into Python》Chapter 2 and Chapter 3 笔记

20170608-chapter 6-《pride and prejudice 傲慢与偏见》精读

Pandas 【Chapter 4】

ST_chapter3

OpenCV入门C++版