~egtann/srp

ref: b26f377adfec2a81fc5b9ba53358050b0ff19bf6 srp/proxy_test.go -rw-r--r-- 653 bytes
b26f377a — Evan Tann add timeout control to transport 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package srp

import (
	"bytes"
	"net/http/httptest"
	"testing"
)

func BenchmarkServeHTTP(b *testing.B) {
	content := `{
		"frontend": {
			"HealthPath": "/health",
			"Backends": ["1", "2"]
		}
	}`
	reg, err := newRegistry(bytes.NewBufferString(content))
	if err != nil {
		panic(err)
	}
	proxy := NewProxy(noopLogger{}, reg)
	w := httptest.NewRecorder()
	r := httptest.NewRequest("GET", "/", nil)
	b.ReportAllocs()
	for i := 0; i < b.N; i++ {
		proxy.ServeHTTP(w, r)
	}
}

type noopLogger struct{}

func (n noopLogger) Printf(format string, vals ...interface{})           {}
func (n noopLogger) ReqPrintf(reqID, format string, vals ...interface{}) {}