Commit a1aee55b authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

net/http: close body in benchmarks

Is it required? Why don't we do it?

R=bradfitz
CC=golang-codereviews
https://golang.org/cl/61150043
parent a50c5fe6
...@@ -2258,7 +2258,9 @@ func BenchmarkClientServer(b *testing.B) { ...@@ -2258,7 +2258,9 @@ func BenchmarkClientServer(b *testing.B) {
if err != nil { if err != nil {
b.Fatal("Get:", err) b.Fatal("Get:", err)
} }
defer res.Body.Close()
all, err := ioutil.ReadAll(res.Body) all, err := ioutil.ReadAll(res.Body)
res.Body.Close()
if err != nil { if err != nil {
b.Fatal("ReadAll:", err) b.Fatal("ReadAll:", err)
} }
...@@ -2301,6 +2303,7 @@ func benchmarkClientServerParallel(b *testing.B, conc int) { ...@@ -2301,6 +2303,7 @@ func benchmarkClientServerParallel(b *testing.B, conc int) {
continue continue
} }
all, err := ioutil.ReadAll(res.Body) all, err := ioutil.ReadAll(res.Body)
res.Body.Close()
if err != nil { if err != nil {
b.Logf("ReadAll: %v", err) b.Logf("ReadAll: %v", err)
continue continue
...@@ -2338,6 +2341,7 @@ func BenchmarkServer(b *testing.B) { ...@@ -2338,6 +2341,7 @@ func BenchmarkServer(b *testing.B) {
log.Panicf("Get: %v", err) log.Panicf("Get: %v", err)
} }
all, err := ioutil.ReadAll(res.Body) all, err := ioutil.ReadAll(res.Body)
res.Body.Close()
if err != nil { if err != nil {
log.Panicf("ReadAll: %v", err) log.Panicf("ReadAll: %v", err)
} }
......
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