This is excellent, really helpful. The -help flag only mentions testing and casual searching only again pops up with info on more testing, I couldn't see anything on actually using it for running a generic binary. Perhaps it would be worth adding this to the documentation?
+ things like not needing the binary as an argument since 1.7 etc. Or maybe just an example in the package file https://golang.org/pkg/runtime/trace/ On Thursday, 20 August 2015 11:40:49 UTC+1, Egon wrote: > > On Wednesday, 19 August 2015 23:32:16 UTC+3, Shan Valleru wrote: >> >> In Go 1.5, it seems like you can generate a execution flow diagram (like >> this - https://talks.golang.org/2015/dynamic-tools/trace.png) for a go >> program using trace command <https://golang.org/doc/go1.5#trace_command>. >> Anybody know the detailed steps for generating such a flow diagram from a >> go program? >> > > Here's the code I used to create a 10s trace from a server. You should be > able to modify it to your own needs. > > import "runtime/trace" > > func trace10(w http.ResponseWriter, r *http.Request) { > f, err := os.Create(time.Now().Format("2006-01-02T150405.pprof")) > if err != nil { > panic(err) > } > defer f.Close() > > if err := trace.Start(f); err != nil { > panic(err) > } > defer trace.Stop() > > // All the important stuff is happening in other goroutines so we just > wait here > time.Sleep(10 * time.Second) > } > > Once you have integrated that into your own code whatever way you need: > > // on Linux you can create/analyze it as: > go build . > ./program > go tool trace program 2015-08-20T133508.pprof > > // on Windows > go build . > program.exe > go tool trace program.exe 2015-08-20T133508.pprof > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.