diff --git a/commands/pilosa-cruncher/cruncher.go b/commands/pilosa-cruncher/cruncher.go index 10d0fc5e9..99d6f947c 100644 --- a/commands/pilosa-cruncher/cruncher.go +++ b/commands/pilosa-cruncher/cruncher.go @@ -1,10 +1,25 @@ package main import ( + "flag" + "log" + "os" "pilosa/cruncher" + "runtime/pprof" ) +var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") + func main() { + flag.Parse() + if *cpuprofile != "" { + f, err := os.Create(*cpuprofile) + if err != nil { + log.Fatal(err) + } + pprof.StartCPUProfile(f) + defer pprof.StopCPUProfile() + } cruncher := cruncher.NewCruncher() cruncher.Run() }