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
|
install: build
|
||||||
go install
|
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 debugging, setup profiling.
|
||||||
if u.Debug {
|
if u.Debug {
|
||||||
ofi, err := os.Create("cpu.prof")
|
ofi, err := os.Create("cpu.prof")
|
||||||
|
defer ofi.Close()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pprof.StartCPUProfile(ofi)
|
pprof.StartCPUProfile(ofi)
|
||||||
defer ofi.Close()
|
|
||||||
defer pprof.StopCPUProfile()
|
defer pprof.StopCPUProfile()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user