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

Function BenchmarkStackdriverLog

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

Source from the content-addressed store, hash-verified

156}
157
158func BenchmarkStackdriverLog(b *testing.B) {
159 ent := &Entry{
160 ReceivedTime: time.Date(2017, time.October, 13, 17, 0, 0, 512, time.UTC),
161 RequestMethod: "POST",
162 RequestURL: "/foo/bar",
163 RequestHeaderSize: 456,
164 RequestBodySize: 123000,
165 UserAgent: "Chrome proxied through Firefox and Edge",
166 Referer: "http://www.example.com/",
167 Proto: "HTTP/1.1",
168 RemoteIP: "12.34.56.78",
169 ServerIP: "127.0.0.1",
170 Status: 404,
171 ResponseHeaderSize: 555,
172 ResponseBodySize: 789000,
173 Latency: 5 * time.Second,
174 }
175 var buf bytes.Buffer
176 l := NewStackdriverLogger(&buf, func(error) {})
177 l.Log(ent)
178 b.ReportAllocs()
179 b.SetBytes(int64(buf.Len()))
180 buf.Reset()
181 b.ResetTimer()
182
183 l = NewStackdriverLogger(io.Discard, func(error) {})
184 for i := 0; i < b.N; i++ {
185 l.Log(ent)
186 }
187}
188
189func BenchmarkE2E(b *testing.B) {
190 run := func(b *testing.B, handler http.Handler) {

Callers

nothing calls this directly

Calls 4

LogMethod · 0.95
NewStackdriverLoggerFunction · 0.85
ResetMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected