1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Add -p/--profile flag to enable cpu/memory profiling

1. Compile the binary with the profiling flag in it.
2. Run the binary with profiling enabled: ./wtf -p
3. Run the go profiling tool against the resulting *.pprof file:

    go tool pprof --pdf /path/to/wtfbinary /var/path/to/cpu.pprof >
profile.pdf

4. View pretty PDF file
This commit is contained in:
Chris Cummer 2018-07-17 10:17:35 -07:00
parent c8ff175a62
commit dc50bce2ed
3 changed files with 8 additions and 0 deletions

2
.gitignore vendored
View File

@ -16,6 +16,8 @@
.DS_Store
gcal/client_secret.json
gspreadsheets/client_secret.json
profile.pdf
#intellij idea
.idea/

View File

@ -13,6 +13,7 @@ import (
type Flags struct {
Config string `short:"c" long:"config" optional:"yes" description:"Path to config file"`
Module string `short:"m" long:"module" optional:"yes" description:"Display info about a specific module, i.e.: 'wtf -m=todo'"`
Profile bool `short:"p" long:"profile" optional:"yes" description:"Profile application memory usage"`
Version bool `short:"v" long:"version" description:"Show version info"`
}

5
wtf.go
View File

@ -8,6 +8,7 @@ import (
"github.com/gdamore/tcell"
"github.com/olebedev/config"
"github.com/pkg/profile"
"github.com/radovskyb/watcher"
"github.com/rivo/tview"
"github.com/senorprogrammer/wtf/bamboohr"
@ -253,6 +254,10 @@ func main() {
cfg.CreateConfigFile()
loadConfigFile(flags.ConfigFilePath())
if flags.Profile {
defer profile.Start(profile.MemProfile).Stop()
}
setTerm()
app := tview.NewApplication()