How it works...
Benchmarking helps us tune applications and do certain micro-optimizations for things such as memory allocations. When benchmarking allocations for applications with input, it's important to try a variety of input sizes to determine if it affects allocations. We wrote two functions, concat and join. Both join together a variadic string parameter with spaces, so the arguments (a, b, c) will return the string a b c.
The concat approach accomplishes this solely through string concatenation. We create a string and append the strings in the list and spaces in a for loop. We omit adding a space on the last loop. The join function uses the internal Strings.Join function to accomplish this far more efficiently in most cases. It can ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access