Commit 399a311e authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

http: client+server benchmark

baseline runs: (6g, gopher.mtv)

http_test.BenchmarkClientServer  5000  412588 ns/op
http_test.BenchmarkClientServer  5000  403346 ns/op
http_test.BenchmarkClientServer  5000  413936 ns/op
http_test.BenchmarkClientServer  5000  410287 ns/op
http_test.BenchmarkClientServer  5000  388037 ns/op
http_test.BenchmarkClientServer  5000  405545 ns/op
http_test.BenchmarkClientServer  5000  405179 ns/op
http_test.BenchmarkClientServer  5000  413827 ns/op
http_test.BenchmarkClientServer  5000  392723 ns/op

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4515155
parent f7a266a5
......@@ -754,3 +754,29 @@ func TestZeroLengthPostAndResponse(t *testing.T) {
}
}
}
func BenchmarkClientServer(b *testing.B) {
b.StopTimer()
ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, r *Request) {
fmt.Fprintf(rw, "Hello world.\n")
}))
defer ts.Close()
b.StartTimer()
for i := 0; i < b.N; i++ {
res, err := Get(ts.URL)
if err != nil {
panic("Get: " + err.String())
}
all, err := ioutil.ReadAll(res.Body)
if err != nil {
panic("ReadAll: " + err.String())
}
body := string(all)
if body != "Hello world.\n" {
panic("Got body: " + body)
}
}
b.StopTimer()
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment