package main import ( "fmt" "os" "runtime" "runtime/trace" "time" debug "runtime/debug" ) func child(c chan string) { for msg := range c { c <- msg } } func main() { f, err := os.Create("trace.out") if err != nil { panic(err) } defer f.Close() if err := trace.Start(f); err != nil { panic(err) } defer trace.Stop() runtime.GOMAXPROCS(1) debug.SetGCPercent(-1) c := make(chan string) go child(c) const niters = 2000000 for i := 0; i < niters; i++ { c <- "test" reply := <-c if len(reply) != 4 { panic("err") } } fmt.Println("done") time.Sleep(1 * time.Second) }