util: pprof: Improve pprof for ease of use

This makes it slightly cleaner.
This commit is contained in:
James Shubin
2025-01-31 00:00:05 -05:00
parent 95f353c6a4
commit 7331d3a7ee
2 changed files with 16 additions and 13 deletions

20
main.go
View File

@@ -77,16 +77,6 @@ func main() {
return // for safety
}
// Run profiling if it's activated.
// TODO: Should we pass a logger into this?
ctx, cancel := context.WithCancel(context.Background())
if err := pprof.Run(ctx); err != nil {
fmt.Println(err)
os.Exit(1)
//return // redundant
}
defer cancel()
cliUtil.LogSetup(debug)
data := &cliUtil.Data{
Program: program,
@@ -102,6 +92,16 @@ func main() {
Args: os.Args,
}
// Run profiling if it's activated.
// TODO: Should we pass a logger into this?
ctx, cancel := context.WithCancel(context.Background())
if err := pprof.Run(ctx); err != nil {
fmt.Println(err)
os.Exit(1)
//return // redundant
}
defer cancel()
name := ""
if len(data.Args) > 1 {
name = data.Args[1]