forked from cloudfoundry/gorouter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
perf_test.go
49 lines (40 loc) · 1.26 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
48
49
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/pivotal-golang/lager/lagertest"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"strconv"
"github.com/cloudfoundry/gorouter/metrics/reporter/fakes"
)
var _ = Describe("AccessLogRecord", func() {
Measure("Register", func(b Benchmarker) {
logger := lagertest.NewTestLogger("test")
c := config.DefaultConfig()
r := registry.NewRouteRegistry(logger, c, new(fakes.FakeRouteRegistryReporter))
accesslog, err := access_log.CreateRunningAccessLogger(logger, c)
Expect(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)
})