MCPcopy Create free account
hub / github.com/google/go-cloud / BenchmarkE2E

Function BenchmarkE2E

server/requestlog/stackdriver_test.go:189–212  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

187}
188
189func BenchmarkE2E(b *testing.B) {
190 run := func(b *testing.B, handler http.Handler) {
191 b.Helper()
192
193 s := httptest.NewServer(handler)
194 defer s.Close()
195 b.ReportAllocs()
196 for i := 0; i < b.N; i++ {
197 resp, err := http.Get(s.URL)
198 if err != nil {
199 b.Fatal(err)
200 }
201 _, _ = io.Copy(io.Discard, resp.Body)
202 _ = resp.Body.Close()
203 }
204 }
205 b.Run("Baseline", func(b *testing.B) {
206 run(b, http.HandlerFunc(benchHandler))
207 })
208 b.Run("WithLog", func(b *testing.B) {
209 l := NewStackdriverLogger(io.Discard, func(error) {})
210 run(b, NewHandler(l, http.HandlerFunc(benchHandler)))
211 })
212}
213
214func benchHandler(w http.ResponseWriter, r *http.Request) {
215 const msg = "Hello, World!"

Callers

nothing calls this directly

Calls 6

NewStackdriverLoggerFunction · 0.85
NewHandlerFunction · 0.85
CloseMethod · 0.65
CopyMethod · 0.65
runFunction · 0.50
GetMethod · 0.45

Tested by

no test coverage detected