2014-04-13 8 views
8

Ich möchte Profil meine Benchmarks von go test -c erzeugt, aber die go tool pprof braucht eine Profildatei in der Regel innerhalb der Hauptfunktion wie this generiert:Wie profile Benchmarks mit dem Tool pprof?

func main() { 
    flag.Parse() 
    if *cpuprofile != "" { 
     f, err := os.Create(*cpuprofile) 
     if err != nil { 
      log.Fatal(err) 
     } 
     pprof.StartCPUProfile(f) 
     defer pprof.StopCPUProfile() 
    } 

Wie kann ich eine Profildatei in meinem Benchmarks erstellen?

Antwort