...
1
2
3
4
5
6
7
8
9
10
11 package main
12
13 import (
14 "bytes"
15 "log"
16 "os"
17 "runtime"
18 "runtime/trace"
19 )
20
21 func main() {
22
23 for i := 0; i < 10; i++ {
24 var buf bytes.Buffer
25 if err := trace.Start(&buf); err != nil {
26 log.Fatalf("failed to start tracing: %v", err)
27 }
28 runtime.GC()
29 trace.Stop()
30 }
31
32
33 if err := trace.Start(os.Stdout); err != nil {
34 log.Fatalf("failed to start tracing: %v", err)
35 }
36 runtime.GC()
37 trace.Stop()
38 }
39
View as plain text