Tracing Our Tool
Learn how to trace our tool.
Overview
The Go profiler is a great tool to help you understand how your program is spending CPU time. However, sometimes a program is spending time waiting for resources to be available. For example, it could be spending time waiting for a network connection or a file to be read. To help you understand those cases, Go provides another tool: the tracer.
Similar to the profiler, the tracer is also integrated with the testing and benchmarking features through the go test
tool. Run the benchmarks again with the -trace
option to create a trace:
Press + to interact
go test -bench . -benchtime=10x -run ^$ -trace trace01.out
goos: linux
goarch: amd64
pkg: usercode/performance/colStats
Benchmark_Run-4 10 685356800 ns/op
PASS
ok usercode/performance/colStats 7.712s
Once the trace is created, view the results with the go tool trace
command: ...
Get hands-on with 1400+ tech skills courses.