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

转载于:https://www.cnblogs.com/oh-mine/p/8667132.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值