robpike / ivy

ivy, an APL-like calculator
Other
1.33k stars 103 forks source link

ivy: close profile file #130

Closed dmitshur closed 1 year ago

dmitshur commented 1 year ago

Balance out f.Create with an f.Close.

Also bail out if StartCPUProfile returns a non-nil error while here.

I'm not sure if this matters or is helpful, but figured I'd ask by sending this PR. (Issue golang/go#26970 suggests there may be some benefit.)

dmitshur commented 1 year ago

Thanks.

I don't know how StartCPUProfile can error, but I suppose it can. Learn something every day.

Me too, learned from looking at the example at https://pkg.go.dev/runtime/pprof#hdr-Profiling_a_Go_program. Its docs say "StartCPUProfile returns an error if profiling is already enabled." and today's implementation indeed seems to only do that.