The pprof tool allows Go applications to collect and export runtime profiling data. It also provides webhooks 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 have expected the pprof tool to be covered in Chapter 11, 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 that benchmarking can be used. As a result, this recipe will largely focus on pprof for analyzing and improving the memory usage of an application.
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/pprofand navigate to this directory.