(b *testing.B)
| 315 | } |
| 316 | |
| 317 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…