1
0
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:
Brian Tiger Chow
2014-10-29 18:12:41 -07:00
parent 79866d3378
commit 1e847059bc
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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()
}