March 2020
Intermediate to advanced
406 pages
8h 39m
English
If there is a particular place in your code that you'd like to profile specifically, you can implement profiling directly around that code. This can be especially useful if you only want to profile a smaller segment of your code, if you want the pprof output to be smaller and more concise, or if you don't want to add additional overhead to known expensive parts of your code by implementing profiling around them. There are separate methodologies for performing CPU and memory profiling around different segments of a code base.
Profiling CPU utilization for a specific chunk of code would look as follows:
function foo() {pprof.StartCPUProfile()defer pprof.StopCPUProfile()...code...}
Profiling memory utilization ...
Read now
Unlock full access