go test命令常用参数总结

benchmark测试
go test -bench=BenchmarkGetMarginYieldStats -run=none -benchmem -memprofile memprofile.out -cpuprofile profile.out
-bench:要运行的benchmark测试函数
-run: 要匹配的单元测试函数,none表示只匹配名称为none的单元测试,也可以用^$来匹配(一般用来跳过单元测试)
-benchmem: 对内存进行分析
-memprofile:指定内存分析的结果文件为memprofile.out
-cpuprofile:指定cpu分析的结果文件为profile.out
生成profile文件后go tool pprof **.test **.out进入pprof分析
如果想查看分配的内存,而不是使用的内存go tool pprof -alloc_space memcpu.test mem.out
topN:查看占用cpu,memeory前n高的函数
list 函数名:展开函数分析
https://go.dev/blog/pprof

posted @ 2022-08-02 18:56  故意写bug  阅读(462)  评论(0)    收藏  举报