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"
|
"os"
|
||||||
"bufio"
|
"bufio"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"runtime/pprof"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var b []byte
|
var b []byte
|
||||||
|
|
||||||
@ -33,6 +37,15 @@ func main() {
|
|||||||
Dlists: *optDlists,
|
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)
|
doc := markdown.Parse(string(b), e)
|
||||||
w := bufio.NewWriter(os.Stdout)
|
w := bufio.NewWriter(os.Stdout)
|
||||||
doc.WriteHtml(w)
|
doc.WriteHtml(w)
|
||||||
|
Loading…
Reference in New Issue
Block a user