diff --git a/cmd/main.go b/cmd/main.go index c634a06..b49d524 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -7,8 +7,12 @@ import ( "os" "bufio" "io/ioutil" + "log" + "runtime/pprof" ) +var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") + func main() { var b []byte @@ -33,6 +37,15 @@ func main() { Dlists: *optDlists, } + if *cpuprofile != "" { + f, err := os.Create(*cpuprofile) + if err != nil { + log.Fatal(err) + } + pprof.StartCPUProfile(f) + defer pprof.StopCPUProfile() + } + doc := markdown.Parse(string(b), e) w := bufio.NewWriter(os.Stdout) doc.WriteHtml(w)