O'Reilly logo
  • WEI EN WEI EN thinks this is interesting:

my overall advice on performance with refactoring is: Most of the time you should ignore it. If your refactoring introduces performance slow-downs, finish refactoring first and do performance tuning afterwards.

From

Cover of Refactoring: Improving the Design of Existing Code

Note

現代的編譯器與快取機制無比聰明,在大多數的時候重構對效能的影響都比實際想像的低。有疑慮時先測試看看,讓數據說話它會比「你以為」更靠譜。

若重構確實造成效能下降時,訣竅是先完成重構的部分,在開始進行效能的調校工作。