Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http/httptest: ResponseRecorder implements WriteString() #11000

Closed
manucorporat opened this issue May 30, 2015 · 2 comments
Closed

net/http/httptest: ResponseRecorder implements WriteString() #11000

manucorporat opened this issue May 30, 2015 · 2 comments

Comments

@manucorporat
Copy link

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().

I propose to implement WriteString(str) in httptest.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.

@bradfitz
Copy link
Contributor

There are so many other differences. But sure. Not for Go 1.5, though, since we're in a freeze.

Send a CL after Go 1.5 is out in early August.

@bradfitz bradfitz added this to the Go1.6 milestone May 30, 2015
@manucorporat
Copy link
Author

@bradfitz thanks for the info. keep the good work!

@golang golang locked and limited conversation to collaborators Sep 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants