Benchmarking Code I

Let’s learn how to benchmark code in Go.

What is benchmarking?

Benchmarking measures the performance of a function or program, allowing us to compare implementations and to understand the performance impact of code changes. Using that information, we can easily reveal the part of the code that needs to be rewritten to improve its performance. It goes without saying that we should not benchmark Go code on a busy machine that is currently being used for other, more important, purposes unless we have a very good reason to do so! Otherwise, we might interfere with the benchmarking process and get inaccurate results, but most importantly, we might generate performance issues on the machine.

Get hands-on with 1400+ tech skills courses.