1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
package main import ( "flag" "os" "runtime/pprof" "github.com/martinlehoux/kagamigo/kcore" ) var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") func main() { flag.Parse() if *cpuprofile != "" { f, err := os.Create(*cpuprofile) kcore.Expect(err, "failed to create CPU profile") pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } }