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  
    16  	go test -trace trace.out pkg
    17  
    18  View the trace in a web browser:
    19  
    20  	go tool trace trace.out
    21  
    22  Generate a pprof-like profile from the trace:
    23  
    24  	go tool trace -pprof=TYPE trace.out > TYPE.pprof
    25  
    26  Supported profile types are:
    27    - net: network blocking profile
    28    - sync: synchronization blocking profile
    29    - syscall: syscall blocking profile
    30    - sched: scheduler latency profile
    31  
    32  Then, you can use the pprof tool to analyze the profile:
    33  
    34  	go tool pprof TYPE.pprof
    35  
    36  Note that while the various profiles available when launching
    37  'go tool trace' work on every browser, the trace viewer itself
    38  (the 'view trace' page) comes from the Chrome/Chromium project
    39  and is only actively tested on that browser.
    40  */
    41  package main
    42  

View as plain text