forked from cloudfoundry/gorouter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
perf_test.go
47 lines (39 loc) · 1.13 KB
/
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
47
package main_test
import (
"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"
"github.com/cloudfoundry/yagnats/fakeyagnats"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"strconv"
)
var _ = Describe("AccessLogRecord", func() {
Measure("Register", func(b Benchmarker) {
c := config.DefaultConfig()
mbus := fakeyagnats.Connect()
r := registry.NewRouteRegistry(c, mbus)
accesslog, err := access_log.CreateRunningAccessLogger(c)
Ω(err).ToNot(HaveOccurred())
proxy.NewProxy(proxy.ProxyArgs{
EndpointTimeout: c.EndpointTimeout,
Ip: c.Ip,
TraceKey: c.TraceKey,
Registry: r,
Reporter: varz.NewVarz(r),
AccessLogger: accesslog,
})
b.Time("RegisterTime", func() {
for i := 0; i < 1000; i++ {
str := strconv.Itoa(i)
r.Register(
route.Uri("bench.vcap.me."+str),
route.NewEndpoint("", "localhost", uint16(i), "", nil, -1),
)
}
})
}, 10)
})