cmd/main.go: add flag -cpuprofile to enable runtime/pprof profiling
This commit is contained in:
parent
13fca5aaab
commit
ec93c2ee28
13
cmd/main.go
13
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)
|
||||
|
Loading…
Reference in New Issue
Block a user