add command line option for profiling
This commit is contained in:
parent
d8cfe7f593
commit
dde01fce0a
13
main.go
13
main.go
@ -7,6 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
|
"runtime/pprof"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -63,11 +64,23 @@ func startServer() {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
serverMode := flag.Bool("server", false, "start server (automatic)")
|
serverMode := flag.Bool("server", false, "start server (automatic)")
|
||||||
|
cpuprofile := flag.String("cpuprofile", "", "path to the file to write the cpu profile")
|
||||||
flag.StringVar(&gLastDirPath, "last-dir-path", "", "path to the file to write the last dir on exit (to use for cd)")
|
flag.StringVar(&gLastDirPath, "last-dir-path", "", "path to the file to write the last dir on exit (to use for cd)")
|
||||||
flag.StringVar(&gSelectionPath, "selection-path", "", "path to the file to write selected files on exit (to use as open file dialog)")
|
flag.StringVar(&gSelectionPath, "selection-path", "", "path to the file to write selected files on exit (to use as open file dialog)")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *cpuprofile != "" {
|
||||||
|
f, err := os.Create(*cpuprofile)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("could not create CPU profile: ", err)
|
||||||
|
}
|
||||||
|
if err := pprof.StartCPUProfile(f); err != nil {
|
||||||
|
log.Fatal("could not start CPU profile: ", err)
|
||||||
|
}
|
||||||
|
defer pprof.StopCPUProfile()
|
||||||
|
}
|
||||||
|
|
||||||
if *serverMode {
|
if *serverMode {
|
||||||
serve()
|
serve()
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user