Once we get an insight into the code via test and profiling results, we need to analyze the bottlenecks worth considering for optimization. A better approach is to find the most underperforming portion and optimize it, thereby eliminating the weakest link. We discussed performance aspects of hardware and JVM/Clojure in previous chapters. Optimization and tuning requires rethinking the design and code in light of those aspects and refactoring for performance objectives.
Once we establish the performance bottlenecks, we have to pinpoint the root cause and experiment with improvisations, one step at a time, to see what works. Tuning for performance is an iterative process backed by measurement, monitoring, and experimentation.
Identifying the nature of the performance bottleneck helps a lot in order to experiment with the right aspects of the code. The key is to determine the origin of cost and whether the cost is reasonable. As a general rule, we have to see if the type hints...