Skip to content

Commit

Permalink
Add benchmark for http requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-feld committed Sep 21, 2021
1 parent 0e75ddd commit 1944a04
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions config/confighttp/confighttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,3 +626,24 @@ func TestHttpHeaders(t *testing.T) {
})
}
}

func BenchmarkHttpRequest(b *testing.B) {

hss := &HTTPServerSettings{
Endpoint: "localhost:0",
}
s := hss.ToServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, errWrite := fmt.Fprint(w, "test")
assert.NoError(b, errWrite)
}))

req := httptest.NewRequest("GET", "/", nil)

for i := 0; i < b.N; i++ {
rw := httptest.NewRecorder()

// Use the handler generated by ToServer for benchmarking
// to avoid network artifacts
s.Handler.ServeHTTP(rw, req)
}
}

0 comments on commit 1944a04

Please sign in to comment.