Go - benchmark cpuprofile

发布时间 2023-09-05 15:41:46作者: ZhangZhihuiAAA

zzh@ZZHPC:/zdata/MyPrograms/Go/aaa$ go test -run NONE -bench .
goos: linux
goarch: amd64
pkg: zzh/aaa
cpu: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
BenchmarkTokenize-6 60164 19742 ns/op
PASS
ok zzh/aaa 1.392s
zzh@ZZHPC:/zdata/MyPrograms/Go/aaa$ go test -run NONE -bench . -cpuprofile=tokenizer.pprof
goos: linux
goarch: amd64
pkg: zzh/aaa
cpu: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
BenchmarkTokenize-6 58401 19679 ns/op
PASS
ok zzh/aaa 1.508s
zzh@ZZHPC:/zdata/MyPrograms/Go/aaa$ go tool pprof -http=:8080 tokenizer.pprof
Serving web UI on http://localhost:8080
Failed to execute dot. Is Graphviz installed?
exec: "dot": executable file not found in $PATH
Failed to execute dot. Is Graphviz installed?
exec: "dot": executable file not found in $PATH
^Cgo tool pprof: signal: interrupt
zzh@ZZHPC:/zdata/MyPrograms/Go/aaa$ sudo apt install graphviz

zzh@ZZHPC:/zdata/MyPrograms/Go/aaa$ go tool pprof -http=:8080 tokenizer.pprof