go test -cover
直接输出覆盖率go test -run TestAll
指定要运行的单元测试函数go test -cover -coverprofile=c.out
go tool cover -html=c.out -o coverage.html
输出具体的代码覆盖状况执行全部函数 go test -bench=".*"
html
执行指定函数 go test -bench="BenchmarkWithPool"
git
生成内存和cpu分析文件 go test -bench="BenchmarkWithPool" -cpuprofile cpu.out -memprofile mem.out
github
分析cpu文件 go tool pprof cpu.out
golang
分析内存文件 go tool pprof mem.out
函数
输出png图 图中红色方块面积越大 证实申请的内存越大或者消耗cpu越多性能
源码连接单元测试