There are three kinds of optimization.
1. Optimization by using a more sensible overall approach.
2. Optimization by making the code less weird.
3. Optimization by making the code more weird.
You've probably heard, and maybe even spouted yourself, the phrase "premature optimization is the root of all evil." It's exclusively "Type 3 optimization" that this aphorism applies to. Types 1 and 2 are quite fine to engage in pre-emptively.
To make a type 3 optimization, your burdens are six:
1. Thou shalt have excellent, comprehensive unit tests.
2. Thou shalt have a reliable benchmark, based on representative inputs.
3. Thou shalt demonstrate that your change improves the benchmark.
4. Thou shalt successfully argue that this improvement really matters.
5. Thou shalt comment the code.
6. In nontrivial cases, thou shalt also preserve the clear-but-slow implementation, to use in parity tests with your optimized implementation.
In all things, remember these truths:
1. Your brain is a terrible profiler.
2. Hotspot will outsmart you.
3. It just doesn't matter, until it matters.
If you believe this post, please spread the word!
分享到:
相关推荐
Bayesian optimization is a powerful tool for the joint optimization of design choices that is gaining great popularity in recent years. It promises greater automation so as to increase both product ...
Handbook of Graph Theory, Combinatorial Optimization, and Algorithms is the first to present a unified, comprehensive treatment of both graph theory and combinatorial optimization. Divided into 11 ...
在本题中,我们面临的是一个使用排队理论解决交通规划问题的案例。排队理论是运筹学的一个分支,它研究和服务系统中等待的个体(如车辆、顾客等)的行为模式。在这个特定的问题中,目标是确定新郊区的道路宽度,即每...
《Convex Optimization - Algorithms and Complexity》(2015 Sébastien Bubeck)即先前《Theory of Convex Optimization for Machine Learning》的升级版
《Practical Methods of Optimization》是R. Fletcher所著的关于优化理论的书籍。本书的第二版详细地介绍了各种实用的优化方法,并广泛应用于各类科学和工程领域。 首先,书名中“Optimization”一词表明了本书的...
标题《Practical Methods of Optimization (Fletcher)》所指向的内容是一本关于最优化的实用方法的教材。作者R. Fletcher,是英国邓迪大学数学系的成员。该书的第二版由Wiley-Interscience出版社在1987年首次出版,...
介绍限制条件上如何求解优化问题。如lagrange multiplier.
《Handbook of Graph Theory, Combinatorial Optimization, and Algorithms》是一本关于图论、组合优化以及算法的电子书,该书为最新版本,属于经典著作系列。根据所提供的内容,此书可能包含以下知识点: 1. 图论...
The authors also discuss the complexity issues and provide an overview of the basic theory of state-of-the-art polynomial time interior point methods for linear, conic quadratic, and semidefinite ...
《Engineering Optimization Theory and Practice 第四版》是工科学生优化理论方法的权威教材,作者Singiresu S. Rao,由John Wiley & Sons出版社出版。本书被广泛认为是工程优化领域中不可或缺的参考书,是理论与...
- 本书的再版信息(Softcover reprint of the hardcover 2nd edition 2004)表明,该书不仅一次印刷,而且对之前的版本进行了更新和再版,说明其内容具有一定的时效性和持续的学术价值。 - 书的封面设计、排版印刷...
The series in Vector Optimization contains publications in various fields of optimization with vector-valued objective functions, such as multiobjective optimization, multi criteria decision making, ...
While the mathematics of convex optimization has been studied for about a century, several related recent developments have stimulated new interest in the topic. The ¯rst is the recognition that ...
This book offers a comprehensive treatment of the theory of measures of noncompactness. It discusses various applications of the theory of measures of noncompactness, in particular, by addressing the ...
《凸优化的应用精选》一书由李莉撰写,属于Springer Optimization and Its Applications系列中的第103卷。该系列旨在出版涵盖解决优化问题算法以及涉及此类问题应用领域的本科生和研究生教材、专著及前沿综述性作品...