https://github.com/facontidavide/CPP_Optimizations_Diary
• Measure first and make hypothesis later.
Linux中的 "常用 "工具是Hotspot(用于性能分析的Linux perf GUI)和Heaptrack(A heap memory profiler for Linux)。这两者就像士兵的步枪和手榴弹
https://github.com/KDAB/hotspot
https://github.com/KDE/heaptrack
一旦你知道哪个部分的代码值得优化,你可能想用Google Benchmark来测量在一个非常具体的类或函数中花费的时间。
https://github.com/google/benchmark
你甚至可以在线测试:

效率比值传递更高。(例外:当复制一个不需要堆分配并且小于几十个字节的对象时,没什么提升)
经验:永远不要传递大小为8字节或更少(整数、双精度浮点数、字符串等)的参数的引用。
比如编写如下代码毫无意义且丑陋:
void YouAreTryingTooHardDude(const int& a, const double& b);

巨大优势:元素在内存中依次紧密排列
将一个元素推入一个空或满的向量时,我们需要: