Using the pprof tool
The pprof tools allows Go applications to collect and export runtime profiling data. It also provides web hooks to access the tool from a web interface. This recipe will create a basic application that verifies a bcrypt hashed password against a plaintext one, then it will profile the application.
You might expect the pprof tool to be in the Chapter 10, Distributed Systems,with other metrics and monitoring recipes. It was instead put in this chapter because it will be used to analyze and improve a program much in the same way benchmarking can be used. As a result, this recipe will largely focus on pprof for analyzing and improving the memory usage of an application.
Getting ready
Configure your environment by performing these steps:
- Refer to the Getting ready section of the Speeding up compilation and testing cycles recipe in this chapter.
- Optionally, install Graphviz from http://www.graphviz.org/Home.php.
How to do it...
These steps cover writing and running your application...