Some applications can benefit a lot from optimization. Consider routers, for example, which we'll look at in a later recipe. Fortunately, the tool benchmark suite provides flags to collect a number of memory allocations as well as memory allocation size. It can be helpful to tune certain critical code paths to minimize these two attributes.
This recipe will show two approaches to writing a function that glues together strings with a space, similar to strings.Join("a", "b", "c"). One approach will use concatenation, while the other will use the strings package. We'll then compare performance and memory allocations between the two.
How to do it...
These steps cover writing and running your application:
- From your Terminal or console application,createa new directory called~/projects/go-programming-cookbook/chapter14/tuningand navigate to this directory. ...