Optimizing Programs
Explore how to optimize Go programs by timing function executions to benchmark performance and using memoization to cache results of expensive pure functions. This lesson helps you understand practical ways to enhance efficiency in your Go applications.
We'll cover the following...
We'll cover the following...
Timing a function
Sometimes it is interesting to know how long a certain computation took, e.g. for comparing and benchmarking calculations. A simple way to do this is to record the start-time before the calculation, and the end-time after the calculation by using the function Now() from the time package. The difference ...