forked from cloudfoundry/gorouter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperf_test.go
46 lines (39 loc) · 965 Bytes
/
perf_test.go
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"github.com/cloudfoundry/yagnats/fakeyagnats"
"strconv"
"testing"
"github.com/cloudfoundry/gorouter/access_log"
"github.com/cloudfoundry/gorouter/config"
"github.com/cloudfoundry/gorouter/proxy"
"github.com/cloudfoundry/gorouter/registry"
"github.com/cloudfoundry/gorouter/route"
"github.com/cloudfoundry/gorouter/varz"
)
const (
Host = "1.2.3.4"
Port = 1234
)
func BenchmarkRegister(b *testing.B) {
c := config.DefaultConfig()
mbus := fakeyagnats.New()
r := registry.NewCFRegistry(c, mbus)
proxy.NewProxy(proxy.ProxyArgs{
EndpointTimeout: c.EndpointTimeout,
Ip: c.Ip,
TraceKey: c.TraceKey,
Registry: r,
Reporter: varz.NewVarz(r),
Logger: access_log.CreateRunningAccessLogger(c),
})
for i := 0; i < b.N; i++ {
str := strconv.Itoa(i)
r.Register(
route.Uri("bench.vcap.me."+str),
&route.Endpoint{
Host: "localhost",
Port: uint16(i),
},
)
}
}