文章目录
前言
pprof性能工具的使用
一、cpu
1.下载实例代码
实例代码地址https://github.com/wolfogre/go-pprof-practice
2.运行项目中的main.go文件
go run main.go
3.查看CPU性能数据
D:\program\goPath\src\bytedance\go-pprof-practice>go tool pprof "http://localhost:6060/debug/pprof/profile?seconds=10"
Fetching profile over HTTP from http://localhost:6060/debug/pprof/profile?seconds=10
Saved profile in C:\Users\helloworld\pprof\pprof.samples.cpu.001.pb.gz
Type: cpu
Time: May 12, 2022 at 8:51am (CST)
Duration: 10.12s, Total samples = 5.43s (53.68%)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top
Showing nodes accounting for 5.30s, 97.61% of 5.43s total
Dropped 27 nodes (cum <= 0.03s)
Showing top 10 nodes out of 18
flat flat% sum% cum cum%
4.62s 85.08% 85.08% 4.62s 85.08% bytedance/go-pprof-practic