mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 02:30:39 +08:00
style(cmd/ipfs/pprof) move defer close to initialization
This commit is contained in:
@ -5,3 +5,11 @@ build:
|
||||
|
||||
install: build
|
||||
go install
|
||||
|
||||
# cpu profiling: `go tool pprof ipfs cpu.prof`
|
||||
# mem profiling: `go tool pprof ipfs ipfs.mprof`
|
||||
|
||||
clean:
|
||||
rm -f cpu.prof
|
||||
rm -f ipfs.mprof
|
||||
rm -f ipfs
|
||||
|
@ -99,12 +99,14 @@ func main() {
|
||||
// if debugging, setup profiling.
|
||||
if u.Debug {
|
||||
ofi, err := os.Create("cpu.prof")
|
||||
defer ofi.Close()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
pprof.StartCPUProfile(ofi)
|
||||
defer ofi.Close()
|
||||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user