Use the go tool trace command to visualize execution traces generated by runtime/trace.
- Generate a trace file by running your program with the
GODEBUGenvironment variable set to enable tracing, or by importingruntime/traceand callingtrace.Start(os.Stdout). - Convert the trace output to a visual format by piping it to
go tool trace.
GODEBUG=trace=1 ./your-program > trace.out
go tool trace trace.out
The command opens an interactive web interface in your default browser to analyze goroutine scheduling, GC pauses, and system calls.