You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say I have a http.HandlerFunc or a http.Hander I want to benchmark.
In a real world situation, this function would received an instance of *http.response which implements WriteString(). A call to io.WriteString(w, str) will execute w.WriteString(str) instead of w.Write([]byte(str)) which save us a unnecessary allocation.
This situation is not consistent with httptest.ResponseRecorder because it does not implement WriteString().
Off topic: maybe we should implement WriteString() in another instances of http.ResponseWriter such as: cgi.response and fcgi.response, but this is probably a different issue.
The text was updated successfully, but these errors were encountered:
Let's say I have a
http.HandlerFunc
or ahttp.Hander
I want to benchmark.In a real world situation, this function would received an instance of
*http.response
which implementsWriteString()
. A call toio.WriteString(w, str)
will executew.WriteString(str)
instead ofw.Write([]byte(str))
which save us a unnecessary allocation.This situation is not consistent with
httptest.ResponseRecorder
because it does not implementWriteString()
.I propose to implement
WriteString(str)
inhttptest.ResponseRecorder
in order to achieve more accurate benchmarks.https://github.com/gin-gonic/go/commit/347b0c5aa60c47ac7a7fc0c0b267c8113ce2e66e
Off topic: maybe we should implement
WriteString()
in another instances of http.ResponseWriter such as: cgi.response and fcgi.response, but this is probably a different issue.The text was updated successfully, but these errors were encountered: