Per.5:不要主观的认为低层次代码一定比高层次代码快
Low-level code sometimes inhibits optimizations. Optimizers sometimes do marvels with high-level code.
低层次代码有时会妨碍优化。有时优化器对高层次代码进行令人赞叹的优化。
Per.6: Don't make claims about performance without measurements
Per.6:不要只是定性抱怨性能问题
Reason(原因)
The field of performance is littered with myth and bogus folklore. Modern hardware and optimizers defy naive assumptions; even experts are regularly surprised.
性能领域的充斥者神话和虚假的传说。先进的硬件和优化器也抵挡不了无知的臆断;哪怕是专家也经常会感觉意外。
Note(注意)
Getting good performance measurements can be hard and require specialized tools.
获得好的性能度量手段很困难,需要特定的工具才行。
Note(注意)
A few simple microbenchmarks using Unix time or the standard-library <chrono> can help dispel the most obvious myths. If you can't measure your complete system accurately, at least try to measure a few of your key operations and algorithms. A profiler can help tell you which parts of your system are performance critical. Often, you will be surprised.
一些使用Unix时间的简单的基准程序或者标准库<chrono>可以帮助驱散大多数明显(不实,译者注)的神话。如果你不能精确地测量整个系统,至少应该测量重要的操作和算法。分析器可以告诉你,系统的哪一部分是性能敏感的。通常,结果会让你意外的。
原文链接
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#per5-dont-assume-that-low-level-code-is-necessarily-faster-than-high-level-code