首先我们得先安装这两个工具:
go get -u github.com/google/pprof
go get github.com/DeanThompson/ginpprof

在ginpprof可以很容易就实现集成pprof服务。

ginpprof.Wrap(router)

启动web服务之后,在浏览器中打开http://localhost:port/debug/pprof/即可看见: 

然后我们打开http://localhost:port/debug/pprof/profile,这个地址会收集30秒内服务的运行情况,这个结果会返回一个profile文件给我们

然后我们就可以使用google的pprof工具链去查看服务的运行情况:

ginpprof.Wrap(router)

注意:

Could not execute dot; may need to install graphviz.

成功之后我们可以在浏览器看到: 

这样我们就可以很简单的查看到我们服务的运行情况了