//测试所有方法
go test
//输出更多的信息
go test -v
//go test -bench xregx正则匹配
//基准测试,运行所有的基准测试方法
go test -bench .
//-benchtime 运行多次时间 10s、1h20s、30m
go test -bench . -benchtime 10s
//-benchtime 运行多次时间 10s、1h20s、30m
//Nx 运行多少次
go test -bench . -benchtime 100x
//所有的test方法和基准测试方法运行10次
go test -bench . -count 10
//指定开启多少个cpu运行,默认是GOMAXPROCS.
go test -bench . -cpu 1,2,4
//benchmem 打印内存分配
go test -bench=. -benchtime 2s -count 2 -benchmem
//分别生成block、cpu、mutex、trace的文件,并用go tool pprof 分析
go test -bench=. -benchtime 2s -count 2 -benchmem -blockprofile block.out -cpuprofile cpu.out -mutexprofile mutex.out -trace trace.out
go tool pprof xxx.out
go test
最新推荐文章于 2024-07-23 14:16:29 发布