2009-08-22

慎用优化算法实现之法

David Chisnall在《How Not To Optimize》提到:
This issue is part of a more general problem. Optimizing for special cases can add some overhead to every use of a function, providing a speed improvement only in special cases. Unless a special case is particularly common, or orders of magnitude slower than every other case, then it's typically not worth the bother.

注:这里的提到优化不是指两算法间的取舍,而是在给定算法和数据结构表示后,算法实现针对特定计算环境的优化。这种优化注定了要增加系统负荷,只不过用了挪移之法顺了特定环境的约束而已。保守些不会犯傻,“保持算法的自然和简单,只有慢到需要优化时才着手优化”。

没有评论: