MCPcopy
hub / github.com/ha/doozerd / Benchmark5DoozerConClientSet

Function Benchmark5DoozerConClientSet

src/pkg/peer/bench_test.go:99–172  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

97
98
99func Benchmark5DoozerConClientSet(b *testing.B) {
100 if b.N < 5 {
101 return
102 }
103 const C = 20
104 b.StopTimer()
105 l := mustListen()
106 defer l.Close()
107 a := l.Addr().String()
108 u := mustListenUDP(a)
109 defer u.Close()
110
111 l1 := mustListen()
112 defer l1.Close()
113 u1 := mustListenUDP(l1.Addr().String())
114 defer u1.Close()
115 l2 := mustListen()
116 defer l2.Close()
117 u2 := mustListenUDP(l2.Addr().String())
118 defer u2.Close()
119 l3 := mustListen()
120 defer l3.Close()
121 u3 := mustListenUDP(l3.Addr().String())
122 defer u3.Close()
123 l4 := mustListen()
124 defer l4.Close()
125 u4 := mustListenUDP(l4.Addr().String())
126 defer u4.Close()
127
128 go Main("a", "X", "", "", "", nil, u, l, nil, 1e9, 1e10, 3e12, 1e9)
129 go Main("a", "Y", "", "", "", dial(a), u1, l1, nil, 1e9, 1e10, 3e12, 1e9)
130 go Main("a", "Z", "", "", "", dial(a), u2, l2, nil, 1e9, 1e10, 3e12, 1e9)
131 go Main("a", "V", "", "", "", dial(a), u3, l3, nil, 1e9, 1e10, 3e12, 1e9)
132 go Main("a", "W", "", "", "", dial(a), u4, l4, nil, 1e9, 1e10, 3e12, 1e9)
133
134 cl := dial(l.Addr().String())
135 cl.Set("/ctl/cal/1", store.Missing, nil)
136 cl.Set("/ctl/cal/2", store.Missing, nil)
137 cl.Set("/ctl/cal/3", store.Missing, nil)
138 cl.Set("/ctl/cal/4", store.Missing, nil)
139
140 waitFor(cl, "/ctl/node/X/writable")
141 waitFor(cl, "/ctl/node/Y/writable")
142 waitFor(cl, "/ctl/node/Z/writable")
143 waitFor(cl, "/ctl/node/V/writable")
144 waitFor(cl, "/ctl/node/W/writable")
145
146 cls := []*doozer.Conn{
147 cl,
148 dial(l1.Addr().String()),
149 dial(l2.Addr().String()),
150 dial(l3.Addr().String()),
151 dial(l4.Addr().String()),
152 }
153
154 done := make(chan bool, C)
155 f := func(i int, cl *doozer.Conn) {
156 for ; i < b.N; i += C {

Callers

nothing calls this directly

Calls 7

mustListenFunction · 0.85
mustListenUDPFunction · 0.85
MainFunction · 0.85
dialFunction · 0.85
waitForFunction · 0.85
SetMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected