@cryptotaxi247 / kubo / commits / 1e847059b

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

Brian Tiger Chow committed Oct 29, 2014 at 18:12 UTC 1e847059bca680639549b82beb4be538d2a1fdbc
2 files changed +11 -1
cmd/ipfs/Makefile
+8
@@ -5,3 +5,11 @@ build:
5
6 install: build
7 go install
8 +
9 +# cpu profiling: `go tool pprof ipfs cpu.prof`
10 +# mem profiling: `go tool pprof ipfs ipfs.mprof`
11 +
12 +clean:
13 + rm -f cpu.prof
14 + rm -f ipfs.mprof
15 + rm -f ipfs
cmd/ipfs/ipfs.go
+3 -1
@@ -99,12 +99,14 @@ func main() {
99 // if debugging, setup profiling.
100 if u.Debug {
101 ofi, err := os.Create("cpu.prof")
102 + defer ofi.Close()
103 +
104 if err != nil {
105 fmt.Println(err)
106 return
107 }
108 +
109 pprof.StartCPUProfile(ofi)
107 - defer ofi.Close()
110 defer pprof.StopCPUProfile()
111 }
112