What is optimization?

Performance를 늘리는 것은 항상 개발자가 해야 하는 것이다. 알고리즘은 차수를 낮출 수 있지만 여기서 constant를 줄이는 것 역시 매우 중요하다. optimize performance은 상수를 줄이는 역할이다. 이제 optimizations에 대해서 알아보자.

  1. Code Motion

computation performed를 줄이는 법, 계산된 문제를 한번에 치환하는 것이다.

마13.png

  1. Reduction in strength

operation에 걸리는 시간을 줄인다.

ex) 32*x → x<<5

multiplication이 제일 오래 걸리고 다음이 add 가장 빠른게 bit 연산이다.

  1. Optimization Blockers

loop 에서 calling strlen의 사용빈도를 줄이므로써 calling에 드는 시간을 아낄 수 있다.

마14.png