Skip to content

Commit

Permalink
Add the ability to generate a CPU profile
Browse files Browse the repository at this point in the history
  • Loading branch information
mpchadwick committed Nov 15, 2020
1 parent e7c8a72 commit 9298d40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dbanon
dbanon.log
dbanon.prof
tmp/*
/bindata
.DS_Store
Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/rhysd/go-github-selfupdate/selfupdate"
"io/ioutil"
"log"
"runtime/pprof"
"os"
)

Expand Down Expand Up @@ -40,9 +41,16 @@ func main() {
silent := flag.Bool("silent", false, "Disable all logging")
logFile := flag.String("log-file", "", "File to write logs to")
logLevel := flag.String("log-level", "", "Specify desired log level")
profile := flag.Bool("profile", false, "Generate a profile")

flag.Parse()

if *profile {
profF, _ := os.Create("dbanon.prof")
pprof.StartCPUProfile(profF)
defer pprof.StopCPUProfile()
}

if *ver {
fmt.Println(version)
os.Exit(0)
Expand Down

0 comments on commit 9298d40

Please sign in to comment.