Source file src/cmd/trace/doc.go
1 // Copyright 2017 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 /* 6 Trace is a tool for viewing trace files. 7 8 Trace files can be generated with: 9 - runtime/trace.Start 10 - net/http/pprof package 11 - go test -trace 12 13 Example usage: 14 Generate a trace file with 'go test': 15 go test -trace trace.out pkg 16 View the trace in a web browser: 17 go tool trace trace.out 18 Generate a pprof-like profile from the trace: 19 go tool trace -pprof=TYPE trace.out > TYPE.pprof 20 21 Supported profile types are: 22 - net: network blocking profile 23 - sync: synchronization blocking profile 24 - syscall: syscall blocking profile 25 - sched: scheduler latency profile 26 27 Then, you can use the pprof tool to analyze the profile: 28 go tool pprof TYPE.pprof 29 30 Note that while the various profiles available when launching 31 'go tool trace' work on every browser, the trace viewer itself 32 (the 'view trace' page) comes from the Chrome/Chromium project 33 and is only actively tested on that browser. 34 */ 35 package main 36