mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
tsweb: add some Benchmarks
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
64334143a1
commit
7bf436ba30
@ -269,3 +269,35 @@ func TestStdHandler(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLogNot200(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
rh := handlerFunc(func(w http.ResponseWriter, r *http.Request) error {
|
||||
// Implicit 200 OK.
|
||||
return nil
|
||||
})
|
||||
discardLogger := func(string, ...interface{}) {}
|
||||
h := StdHandlerNo200s(rh, discardLogger)
|
||||
req := httptest.NewRequest("GET", "/", nil)
|
||||
rw := new(httptest.ResponseRecorder)
|
||||
for i := 0; i < b.N; i++ {
|
||||
*rw = httptest.ResponseRecorder{}
|
||||
h.ServeHTTP(rw, req)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLog(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
rh := handlerFunc(func(w http.ResponseWriter, r *http.Request) error {
|
||||
// Implicit 200 OK.
|
||||
return nil
|
||||
})
|
||||
discardLogger := func(string, ...interface{}) {}
|
||||
h := StdHandler(rh, discardLogger)
|
||||
req := httptest.NewRequest("GET", "/", nil)
|
||||
rw := new(httptest.ResponseRecorder)
|
||||
for i := 0; i < b.N; i++ {
|
||||
*rw = httptest.ResponseRecorder{}
|
||||
h.ServeHTTP(rw, req)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user