C++核心准则Per.5,6 关于性能的误解
Per.5: Don't assume that low-level code is necessarily faster than high-level code
Per.5:不要主观的认为低层次代码一定比高层次代码快
Reason(原因)
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
一些使用Unix时间的简单的基准程序或者标准库
原文链接
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#per5-dont-assume-that-low-level-code-is-necessarily-faster-than-high-level-code
觉得本文有帮助?请分享给更多人。
关注微信公众号【面向对象思考】轻松学习每一天!
面向对象开发,面向对象思考!