Chinaunix首页 | 论坛 | 博客
  • 博客访问: 306349
  • 博文数量: 55
  • 博客积分: 4000
  • 博客等级: 上校
  • 技术积分: 615
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-07 13:47
文章分类
文章存档

2011年(1)

2010年(2)

2009年(14)

2008年(38)

我的朋友

分类:

2009-02-12 02:20:02

对于编译器的开发者来说,其最重要的原则就是:性能就是一切!
在做编译器的开发时候,需要注意的方面包括:有意义的错误信息提示;好的帮助文档;以及编译器产品支持。相对于这些,用户认为更重要的是其raw speed。编译器的性能包括两个方面:代码的运行时间和将代码编译成可执行的二进制代码所需要的时间。通常,代码的运行时间会占主导地位,起着决定的作用。
一些编译器优化代码的时候会延长编译的时间,但是却减少了代码的运行时间。还有一些编译器既能减少编译的时间以及代码的执行时间,同时还会降低占用的内存空间。优化的负面影响是无效的结果可能不能够被及时发现。优化的时候应当十分小心,如果程序员写无效的代码,就会坏的结果。
这些就是性能非常重要的原因。如果你没有得到正确的结果,及时速度有多快,都没有什么意义了。编译器通常都提供编译优化选项。
The Golden Rule of Compiler-Writers:
Performance Is (almost) Everything.
Performance is almost everything in a compiler. There are other concerns: meaningful error
messages, good documentation, and product support. These factors pale in comparison with
the importance users place on raw speed. Compiler performance has two aspects: runtime
performance (how fast the code runs) and compile time performance (how long it takes to
generate code). Runtime performance usually dominates, except in development and student
environments.
Many compiler optimizations cause longer compilation times but make run times much
shorter. Other optimizations (such as dead code elimination, or omitting runtime checks)
speed up both compile time and run time, as well as reducing memory use. The downside of
aggressive optimization is the risk that invalid results may not be flagged. Optimizers are
very careful only to do safe transformations, but programmers can trigger bad results by
writing invalid code (e.g., referencing outside an array's bounds because they "know" that
the desired variable is adjacent).
This is why performance is almost but not quite everything—if you don't get accurate
results, then it's immaterial how fast you get them. Compiler-writers usually provide
compiler options so each programmer can choose the desired optimizations. B's lack of
success, until Dennis Ritchie created a high-performance compiled version called "New B,"
illustrates the golden rule for compiler-writers.
阅读(1200) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~