Commit 1e847059 authored by Brian Tiger Chow's avatar Brian Tiger Chow

style(cmd/ipfs/pprof) move defer close to initialization

parent 79866d33
...@@ -5,3 +5,11 @@ build: ...@@ -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() { ...@@ -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()
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment