proposal: net/http/httptest: ResponseRecorder.Reset #73544
Labels
LibraryProposal
Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool
Proposal
Milestone
Proposal Details
While benchmarking my ServeHTTP function I noticed that httptest.NewRecorded took a significant time and does 3 allocations.
I removed the
httptest.NewRecorder()
overhead by using the following codeBut I get a warning that direct access to HeaderMap is deprecated. I don’t know if my reset is correct. Apparently, it works.
Benchmarking
httptest.NewRecorder()
yields 172ns/op 160 B/op 3 allocs/op. The Reset method I use yields 2.95ns/op, 0 B/op and 0 allocs/op.A
Reset
method could significantly reduce the overhead of the recorder instantiation and make it straightforward how to reset the recorder.The text was updated successfully, but these errors were encountered: