问题:
There are plenty of performance questions on this site already, but it occurs to me that almost all are very problem-specific and fairly narrow. 这个网站上已经有很多性能问题,但我发现几乎所有问题都是针对特定问题而且相当狭窄。 And almost all repeat the advice to avoid premature optimization. 几乎所有人都重复这些建议,以避免过早优化。
Let's assume: 我们假设:
- the code already is working correctly 代码已经正常工作
- the algorithms chosen are already optimal for the circumstances of the problem 所选择的算法对于问题的情况已经是最佳的
- the code has been measured, and the offending routines have been isolated 已经测量了代码,并且已经隔离了违规的例程
- all attempts to optimize will also be measured to ensure they do not make matters worse 所有优化尝试也将被测量,以确保它们不会使事情变得更糟
What I am looking for here is strategies and tricks to squeeze out up to the last few percent in a critical algorithm when there is nothing else left to do but whatever it takes. 我在这里寻找的是在一个关键算法中挤出最后几个百分点的策略和技巧,除此之外别无他法。
Ideally, try to make answers language agnostic, and indicate any down-sides to the suggested strategies where applicable. 理想情况下,尝试使答案语言不可知,并在适用的情况下指出建议策略的任何缺点。
I'll add a reply with my own initial suggestions, and look forward to whatever else the Stack Overflow community can think of. 我将使用我自己的初步建议添加回复,并期待Stack Overflow社区可以想到的任何其他内容。
解决方案:
参考一: https://stackoom.com/question/3sxm/最后的性能优化策略-关闭参考二: https://oldbug.net/q/3sxm/Performance-optimization-strategies-of-last-resort-closed
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4399207