OSDN Git Service

delete miner
[bytom/vapor.git] / vendor / github.com / go-kit / kit / sd / benchmark_test.go
1 package sd
2
3 import (
4         "io"
5         "testing"
6
7         "github.com/go-kit/kit/endpoint"
8         "github.com/go-kit/kit/log"
9 )
10
11 func BenchmarkEndpoints(b *testing.B) {
12         var (
13                 ca      = make(closer)
14                 cb      = make(closer)
15                 cmap    = map[string]io.Closer{"a": ca, "b": cb}
16                 factory = func(instance string) (endpoint.Endpoint, io.Closer, error) { return endpoint.Nop, cmap[instance], nil }
17                 c       = newEndpointCache(factory, log.NewNopLogger(), endpointerOptions{})
18         )
19
20         b.ReportAllocs()
21
22         c.Update(Event{Instances: []string{"a", "b"}})
23
24         b.RunParallel(func(pb *testing.PB) {
25                 for pb.Next() {
26                         c.Endpoints()
27                 }
28         })
29 }