-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
146 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 前端优化技巧 | ||
|
||
# 后端优化技巧 | ||
|
||
## 常量折叠 | ||
|
||
在编译时期就计算出常量或者子表达式的值,而不是在运行时才发送代码去计算结果 | ||
|
||
## 常量传播 | ||
|
||
如果能确定在前面的代码中某变量被赋值以常量,那么将要访问该变量的地方替换成常量值. | ||
|
||
## 死代码消除 | ||
|
||
删除那些与特定源代码语句(其结果从未被使用过,或者条件块从不为True)关联的目标码. | ||
|
||
## 公共子表达式消除 | ||
|
||
如果子表达式中变量值并未改变,就将其缓存,而无需在下次出现时重复计算该表达式的值. | ||
|
||
## 强度消弱 | ||
|
||
采用与源代码不同的运算符(开销小)来直接计算出结果. | ||
|
||
## 归纳 | ||
|
||
许多表达式中某个变量值完全依赖于其他某个变量,这时省去对其新值的计算,或者在循环内将变量值计算与表达式计算合并. | ||
|
||
## 循环不变量 | ||
|
||
不会随着每轮循环改变的表达式,只要在循环外一次计算出其结果,然后”代码移动”将其移出循环体. | ||
|
||
## 窥孔优化/局部优化 | ||
|
||
编译器仅仅在一个基本块或者多个基本块中,针对已经生成的代码,结合CPU自己指令(或者虚拟机指令)的特点,通过一些认为可能带来性能提升的转换规则,或者通过整体的分析,通过指令转换,提升代码性能。 | ||
|
||
|
||
# 参考实现 | ||
- cython | ||
- pypy | ||
- [编译器,优化,及目标代码生成](https://www.cnblogs.com/robyn/p/3779553.html) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.