Metrics and measurement are at the root of optimization. The adage You can't improve what you can't measure rings true with performance. To be able to make intelligent decisions about performance optimizations, we must continuously measure the performance of the functions we are trying to optimize.
As we mentioned in Chapter 1, Introduction to Performance in Go, the Go creators made performance a forethought in their language design. The Go testing package (https://golang.org/pkg/testing/) is used to test Go code in a systematic way. The testing package is a fundamental part of the Go language. This package also includes a helpful built-in benchmarking functionality. This functionality, which is invoked by go test -bench, runs the benchmarks that you've defined for your functions. The results from your tests can also be saved and viewed...