MCPcopy
hub / github.com/coredns/coredns / BenchmarkYield

Function BenchmarkYield

plugin/pkg/proxy/persistent_test.go:317–343  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

315}
316
317func BenchmarkYield(b *testing.B) {
318 s := dnstest.NewServer(func(w dns.ResponseWriter, r *dns.Msg) {
319 ret := new(dns.Msg)
320 ret.SetReply(r)
321 w.WriteMsg(ret)
322 })
323 defer s.Close()
324
325 tr := newTransport("BenchmarkYield", s.Addr)
326 tr.Start()
327 defer tr.Stop()
328
329 c, _, _ := tr.Dial("udp")
330
331 b.ReportAllocs()
332
333 for b.Loop() {
334 tr.Yield(c)
335 // Simulate FIFO consumption: remove from front
336 tr.mu.Lock()
337 if len(tr.conns[typeUDP]) > 0 {
338 tr.conns[typeUDP] = tr.conns[typeUDP][1:]
339 }
340 tr.mu.Unlock()
341 runtime.Gosched()
342 }
343}

Callers

nothing calls this directly

Calls 8

CloseMethod · 0.95
NewServerFunction · 0.92
newTransportFunction · 0.85
DialMethod · 0.80
YieldMethod · 0.80
StopMethod · 0.65
WriteMsgMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…