Tips on Compiler Optimization
Useful tips and tricks for programming in Go.
We'll cover the following...
We'll cover the following...
Compiler Optimizations
You can pass specific compiler flags to see what optimizations are being applied as well as how some aspects of memory management. This is an advanced feature, mainly for people who want to understand some of the compiler optimizations in place.
Let’s take the following code example from an earlier chapter:
Build your file (here called t.go) passing some gcflags:
The compiler notices that it can inline the NewUser function defined on line
15 and inline it on line 21.
Dave Cheney has a great post about why Go’s inlining is helping your
programs run faster.
Basically, the compiler moves the ...