Go's Pprof Pack
Go has pprof packages for code performance monitoring in two places with packages:
Net/http/pprof
Runtime/pprof
In fact, net/http/pprof only use the RUNTIME/PPROF package to encapsulate a bit, and exposed on the HTTP port.
This article only tells you how to view performance on the web.
First, the code part
1.import Add Net/http/pprof Pack
Import ( _ net/http/pprof)
2. Open the HTTP listening port
go func () { log. Println (http. Listenandserve ("localhost:10000", Nil)} ()
Second, the page to view
* Browser can open http://127.0.0.1:10000/debug/pprof/to view various profile indexes
1. If you have installed Graphviz directly submitted this step, otherwise you can download to http://www.graphviz.org/download/, and add the bin to the environment variable
2. View Profile: Input at the command line
Go Tool pprof Http://localhost:10000/debug/pprof/profile
The following 30 seconds enter the status of the collection profile information.
Enter Pprof interactive mode after 30 seconds, then enter
Web
Then the browser automatically bounces to the Web page to display the SVG diagram
3. View the profile file that has been saved
Go Tool pprof Profile C:\Users\user\pprof\pprof.samples.cpu.004.pb.gz
Then it is also the interactive mode to enter Pprof, then enter the Web
You can also view the heap and Goroutine